-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…#6017) ### Description Allows enabling multiple funboxes that have a stylesheet. Which funboxes should be deemed compatible with each other will need some discussion --------- Co-authored-by: Jack <[email protected]> Co-authored-by: Christian Fehmer <[email protected]>
- Loading branch information
1 parent
a4b6c17
commit a4b7c00
Showing
13 changed files
with
164 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import * as List from "../src/list"; | ||
import * as Validation from "../src/validation"; | ||
import { FunboxMetadata } from "../src/types"; | ||
|
||
describe("validation", () => { | ||
describe("checkCompatibility", () => { | ||
const getFunboxMock = vi.spyOn(List, "getFunbox"); | ||
|
||
beforeEach(() => { | ||
getFunboxMock.mockReset(); | ||
}); | ||
|
||
it("should pass without funboxNames", () => { | ||
//WHEN / THEN | ||
expect(Validation.checkCompatibility([])).toBe(true); | ||
}); | ||
|
||
it("should fail for undefined funboxNames", () => { | ||
//GIVEN | ||
getFunboxMock.mockReturnValueOnce([ | ||
{ | ||
name: "plus_one", | ||
} as FunboxMetadata, | ||
undefined as unknown as FunboxMetadata, | ||
]); | ||
|
||
//WHEN / THEN | ||
expect(Validation.checkCompatibility(["plus_one", "plus_two"])).toBe( | ||
false | ||
); | ||
}); | ||
|
||
it("should fail for undefined withFunbox param", () => { | ||
//GIVEN | ||
getFunboxMock | ||
.mockReturnValueOnce([]) | ||
.mockReturnValue([undefined as unknown as FunboxMetadata]); | ||
|
||
//WHEN / THEN | ||
expect( | ||
Validation.checkCompatibility(["plus_one", "plus_two"], "plus_three") | ||
).toBe(false); | ||
}); | ||
|
||
it("should check for optional withFunbox param ", () => { | ||
//GIVEN | ||
getFunboxMock | ||
.mockReturnValueOnce([ | ||
{ | ||
name: "plus_one", | ||
cssModifications: ["body", "main"], | ||
} as FunboxMetadata, | ||
{ | ||
name: "plus_two", | ||
} as FunboxMetadata, | ||
]) | ||
.mockReturnValueOnce([ | ||
{ | ||
name: "plus_three", | ||
cssModifications: ["main", "typingTest"], | ||
} as FunboxMetadata, | ||
]); | ||
|
||
//WHEN | ||
const result = Validation.checkCompatibility( | ||
["plus_one", "plus_two"], | ||
"plus_three" | ||
); | ||
|
||
//THEN | ||
expect(result).toBe(false); | ||
|
||
expect(getFunboxMock).toHaveBeenNthCalledWith(1, [ | ||
"plus_one", | ||
"plus_two", | ||
]); | ||
expect(getFunboxMock).toHaveBeenNthCalledWith(2, "plus_three"); | ||
}); | ||
|
||
it("should reject two funboxes modifying the same css element", () => { | ||
//GIVEN | ||
getFunboxMock.mockReturnValueOnce([ | ||
{ | ||
name: "plus_one", | ||
cssModifications: ["body", "main"], | ||
} as FunboxMetadata, | ||
{ | ||
name: "plus_two", | ||
cssModifications: ["main", "typingTest"], | ||
} as FunboxMetadata, | ||
]); | ||
|
||
//WHEN / THEN | ||
expect(Validation.checkCompatibility(["plus_one", "plus_two"])).toBe( | ||
false | ||
); | ||
}); | ||
|
||
it("should allow two funboxes modifying different css elements", () => { | ||
//GIVEN | ||
getFunboxMock.mockReturnValueOnce([ | ||
{ | ||
name: "plus_one", | ||
cssModifications: ["body", "main"], | ||
} as FunboxMetadata, | ||
{ | ||
name: "plus_two", | ||
cssModifications: ["words"], | ||
} as FunboxMetadata, | ||
]); | ||
|
||
//WHEN / THEN | ||
expect(Validation.checkCompatibility(["plus_one", "plus_two"])).toBe( | ||
true | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.