forked from wednesday-solutions/react-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
selectors.test.js
41 lines (36 loc) · 1.18 KB
/
selectors.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { selectHomeContainerDomain, selectRepoName, selectReposData, selectReposError } from '../selectors';
import { initialState } from '../reducer';
describe('HomeContainer selector tests', () => {
let mockedState;
let repoName;
let reposData;
let reposError;
beforeEach(() => {
repoName = 'mac';
reposData = { totalCount: 1, items: [{ repoName }] };
reposError = 'There was some error while fetching the repository details';
mockedState = {
homeContainer: {
repoName,
reposData,
reposError
}
};
});
it('should select the repoName', () => {
const repoSelector = selectRepoName();
expect(repoSelector(mockedState)).toEqual(repoName);
});
it('should select reposData', () => {
const reposDataSelector = selectReposData();
expect(reposDataSelector(mockedState)).toEqual(reposData);
});
it('should select the reposError', () => {
const reposErrorSelector = selectReposError();
expect(reposErrorSelector(mockedState)).toEqual(reposError);
});
it('should select the global state', () => {
const selector = selectHomeContainerDomain(initialState);
expect(selector).toEqual(initialState);
});
});