-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a checkSelection selector module and expose a getHostCheckSelecti…
…on selector
- Loading branch information
1 parent
63a70de
commit f141d5f
Showing
2 changed files
with
38 additions
and
0 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,6 @@ | ||
import { TARGET_HOST } from '@lib/model'; | ||
|
||
export const getHostCheckSelection = | ||
(hostID) => | ||
({ checksSelection }) => | ||
checksSelection?.[TARGET_HOST][hostID] || {}; |
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,32 @@ | ||
import { faker } from '@faker-js/faker'; | ||
import { getHostCheckSelection } from './checksSelection'; | ||
|
||
describe('Checks Selection selector', () => { | ||
it(`should get a host's check selection state`, () => { | ||
const hostID = faker.datatype.uuid(); | ||
expect( | ||
getHostCheckSelection(hostID)({ | ||
checksSelection: { | ||
host: { | ||
[faker.datatype.uuid()]: { status: 'successfully_saved' }, | ||
[hostID]: { status: 'saving' }, | ||
}, | ||
}, | ||
}) | ||
).toEqual({ status: 'saving' }); | ||
}); | ||
|
||
it(`should not get a host's check selection state if not present`, () => { | ||
const hostWithoutSelection = faker.datatype.uuid(); | ||
expect( | ||
getHostCheckSelection(hostWithoutSelection)({ | ||
checksSelection: { | ||
host: { | ||
[faker.datatype.uuid()]: { status: 'successfully_saved' }, | ||
[faker.datatype.uuid()]: { status: 'saving' }, | ||
}, | ||
}, | ||
}) | ||
).toEqual({}); | ||
}); | ||
}); |