This repository has been archived by the owner on Feb 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#115): added dynamic import to redux implementation
- Loading branch information
Andreas Gasser
committed
May 21, 2019
1 parent
da9e6f8
commit 8f295e0
Showing
15 changed files
with
300 additions
and
77 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,29 @@ | ||
import getStore from '../getStore'; | ||
|
||
describe('getStore test suite', () => { | ||
it('should create and return store & persistor', () => { | ||
const { store, persistor } = getStore(); | ||
expect(store).toBeTruthy(); | ||
expect(persistor).toBeTruthy(); | ||
}); | ||
|
||
it('should return singleton store & persistor instance', () => { | ||
const { store, persistor } = getStore(); | ||
expect(store).toBeTruthy(); | ||
expect(persistor).toBeTruthy(); | ||
|
||
const newStore = getStore(); | ||
expect(newStore.store).toEqual(store); | ||
expect(newStore.persistor).toEqual(persistor); | ||
}); | ||
|
||
it('should recreate store if force is set', () => { | ||
const { store, persistor } = getStore(); | ||
expect(store).toBeTruthy(); | ||
expect(persistor).toBeTruthy(); | ||
|
||
const secondGetStore = getStore({ force: true }); | ||
expect(store).not.toEqual(secondGetStore.store); | ||
expect(persistor).not.toEqual(secondGetStore.store); | ||
}); | ||
}); |
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,40 +1,9 @@ | ||
import rootReducer from '../rootReducer'; | ||
|
||
import { appIdle, appReset, __testables__ as applicationTestables } from '../application'; | ||
import { __testables__ as authTestables } from '../auth'; | ||
|
||
const { applicationDidLoad } = applicationTestables; | ||
const { authSetToken } = authTestables; | ||
|
||
describe('root reducer test suite', () => { | ||
let mockedDateNow; | ||
|
||
beforeAll(() => { | ||
const now = Date.now(); | ||
mockedDateNow = jest.spyOn(Date, 'now').mockImplementation(() => now); | ||
}); | ||
|
||
afterAll(() => { | ||
mockedDateNow.restoreMock(); | ||
}); | ||
|
||
const firstLevelKeys = ['appTime', 'application', 'auth', 'images', 'labels', 'faces', 'user']; | ||
|
||
it('should return root redux tree', () => { | ||
const rootState = rootReducer(undefined, appIdle()); | ||
expect(Object.keys(rootState)).toEqual(firstLevelKeys); | ||
}); | ||
|
||
it('should reset reducer data on APP_RESET', () => { | ||
// fire some actions to reducer | ||
const rootState1 = rootReducer(undefined, appIdle()); | ||
const rootState2 = rootReducer(rootState1, applicationDidLoad()); | ||
const rootState3 = rootReducer(rootState2, authSetToken('invalid token')); | ||
|
||
// check for non empty redux state | ||
expect(rootState3).not.toEqual(rootReducer(undefined, appIdle)); | ||
const firstLevelKeys = ['appTime', 'application', 'auth']; | ||
|
||
// fire reset and check again | ||
expect(rootReducer(rootState3, appReset())).toEqual(rootState1); | ||
it('should return root redux object tree', () => { | ||
expect(Object.keys(rootReducer)).toEqual(firstLevelKeys); | ||
}); | ||
}); |
Oops, something went wrong.