-
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 domain function
- Loading branch information
Showing
12 changed files
with
2,400 additions
and
149 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"node": "current" | ||
} | ||
} | ||
] | ||
] | ||
} |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
55 changes: 28 additions & 27 deletions
55
src/domain/user-preferences/preference-entry.util.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 |
---|---|---|
@@ -1,34 +1,35 @@ | ||
import { jest } from '@jest/globals'; | ||
|
||
const existingConfigurationId = 'an_existing_configuration_id'; | ||
const existingConfiguration = { | ||
id: existingConfigurationId, | ||
target: 'application', | ||
label: 'Configuration 1', | ||
description: 'Description 1', | ||
values: [ | ||
{ | ||
label: 'Value 1', | ||
value: 'value1' | ||
} | ||
] | ||
}; | ||
jest.mock('@/domain/configuration/configuration.library.json', () => [ | ||
existingConfiguration | ||
]); | ||
const existingConfiguration = [ | ||
{ | ||
id: 'an_existing_configuration_id', | ||
target: 'application', | ||
label: 'Configuration 1', | ||
description: 'Description 1', | ||
values: [ | ||
{ | ||
label: 'Value 1', | ||
value: 'value1' | ||
} | ||
] | ||
} | ||
]; | ||
jest.mock('@/domain/user-preferences/map.json', () => existingConfiguration); | ||
|
||
import { retrieveConfigurationSettings } from '@/domain/user-preferences/configurationLibrary.util.js'; | ||
import { findPreferenceEntryById } from '@/domain/user-preferences/preference-entry.util'; | ||
|
||
beforeEach(() => { | ||
jest.resetModules(); | ||
}); | ||
describe('Preference entries', () => { | ||
it('An existing preference entry must return data successfully', () => { | ||
const configuration = findPreferenceEntryById(existingConfigurationId); | ||
|
||
describe('Configuration', () => { | ||
it('An existing configuration ID must return the configuration data successfully', () => { | ||
const configuration = retrieveConfigurationSettings( | ||
existingConfigurationId | ||
); | ||
expect(configuration).toMatchObject(existingConfiguration.at(0)); | ||
}); | ||
|
||
expect(configuration).toMatchObject(existingConfiguration); | ||
it('An unknown preference entry must thrown an exception', () => { | ||
const unknownPreferenceEntryId = 'an_unknown_preference_entry_id'; | ||
expect(() => | ||
findPreferenceEntryById(unknownPreferenceEntryId) | ||
).toThrowError( | ||
`Unable to find ${unknownPreferenceEntryId} on preference entries list` | ||
); | ||
}); | ||
}); |