-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ #133 add unit test for preference entries loader
- Loading branch information
Showing
5 changed files
with
92 additions
and
30 deletions.
There are no files selected for viewing
23 changes: 22 additions & 1 deletion
23
src/jagfx/core/configuration/preference-entry/filter.spec.js
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
28 changes: 22 additions & 6 deletions
28
src/jagfx/core/configuration/preference-entry/finder.spec.js
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
36 changes: 36 additions & 0 deletions
36
src/jagfx/core/configuration/preference-entry/loader.spec.js
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,36 @@ | ||
import { loadPreferenceEntryValues } from "@/jagfx/core/configuration/preference-entry/loader"; | ||
|
||
const mockPreferenceEntry = (values) => ({ | ||
values, | ||
}); | ||
|
||
describe("Preference entries finder", () => { | ||
// Array not empty > Return this array | ||
// Array empty > Perform external request | ||
// Null > No value, return null | ||
it("Should return the same array if preference entry value is an array not empty", () => { | ||
const preferenceEntry = mockPreferenceEntry(["some", "stuff"]); | ||
|
||
expect(loadPreferenceEntryValues(preferenceEntry)).toBe( | ||
preferenceEntry.values | ||
); | ||
}); | ||
|
||
const invalidPreferenceEntries = [ | ||
{}, | ||
"", | ||
"string", | ||
123, | ||
undefined, | ||
null, | ||
new Event(""), | ||
{ label: "" }, | ||
mockPreferenceEntry(null), | ||
]; | ||
it.each(invalidPreferenceEntries)( | ||
"Should return null with invalid preferenceEntry", | ||
(invalidPreferenceEntry) => { | ||
expect(loadPreferenceEntryValues(invalidPreferenceEntry)).toBeNull(); | ||
} | ||
); | ||
}); |
22 changes: 0 additions & 22 deletions
22
src/jagfx/core/configuration/preference-entry/preference-entry.mock.js
This file was deleted.
Oops, something went wrong.