forked from ngrx/platform
-
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.
Moved config stuff to corresponding file and refined some tests
- Loading branch information
1 parent
d34b88a
commit 29fd07e
Showing
4 changed files
with
116 additions
and
54 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 |
---|---|---|
@@ -1,28 +1,88 @@ | ||
import { ActionReducer, Action } from '@ngrx/store'; | ||
import { StoreDevtoolsConfig } from '../'; | ||
import { | ||
createConfig, | ||
StoreDevtoolsConfig, | ||
noMonitor, | ||
DEFAULT_NAME, | ||
} from '../src/config'; | ||
|
||
describe('StoreDevtoolsOptions', () => { | ||
it('can be initialized with name', () => { | ||
const options = new StoreDevtoolsConfig(); | ||
options.name = 'my instance'; | ||
expect(options.name).toBe('my instance'); | ||
it('creates default options with empty object given', () => { | ||
const config = createConfig({}); | ||
expect(config).toEqual({ | ||
maxAge: false, | ||
monitor: noMonitor, | ||
actionSanitizer: undefined, | ||
stateSanitizer: undefined, | ||
name: DEFAULT_NAME, | ||
serialize: false, | ||
logOnly: false, | ||
features: false, | ||
}); | ||
}); | ||
|
||
it('can be initialized with actionSanitizer', () => { | ||
const options = new StoreDevtoolsConfig(); | ||
function sanitizer(action: Action, id: number): Action { | ||
it('creates options that contain passed in options', () => { | ||
function stateSanitizer(state: any, index: number): any { | ||
return state; | ||
} | ||
function actionSanitizer(action: Action, id: number): Action { | ||
return action; | ||
} | ||
options.actionSanitizer = sanitizer; | ||
expect(options.actionSanitizer).toEqual(sanitizer); | ||
const config = createConfig({ | ||
maxAge: 20, | ||
actionSanitizer, | ||
stateSanitizer, | ||
name: 'ABC', | ||
serialize: true, | ||
features: { | ||
test: true, | ||
}, | ||
}); | ||
expect(config).toEqual({ | ||
maxAge: 20, | ||
monitor: noMonitor, | ||
actionSanitizer, | ||
stateSanitizer, | ||
name: 'ABC', | ||
serialize: true, | ||
logOnly: false, | ||
features: { | ||
test: true, | ||
}, | ||
}); | ||
}); | ||
|
||
it('can be initialized with stateSanitizer', () => { | ||
const options = new StoreDevtoolsConfig(); | ||
function stateSanitizer(state: any, index: number): any { | ||
return state; | ||
} | ||
options.stateSanitizer = stateSanitizer; | ||
expect(options.stateSanitizer).toEqual(stateSanitizer); | ||
it('can be initialized with a function returning options', () => { | ||
const config = createConfig(() => ({ maxAge: 15 })); | ||
expect(config).toEqual({ | ||
maxAge: 15, | ||
monitor: noMonitor, | ||
actionSanitizer: undefined, | ||
stateSanitizer: undefined, | ||
name: DEFAULT_NAME, | ||
serialize: false, | ||
logOnly: false, | ||
features: false, | ||
}); | ||
}); | ||
|
||
it('logOnly will set features', () => { | ||
const config = createConfig({ | ||
logOnly: true, | ||
}); | ||
expect(config).toEqual({ | ||
maxAge: false, | ||
monitor: noMonitor, | ||
actionSanitizer: undefined, | ||
stateSanitizer: undefined, | ||
name: DEFAULT_NAME, | ||
serialize: false, | ||
logOnly: true, | ||
features: { | ||
pause: true, | ||
export: true, | ||
test: true, | ||
}, | ||
}); | ||
}); | ||
}); |
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