forked from ProjectMirador/research-and-demos
-
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.
Merge pull request ProjectMirador#81 from ProjectMirador/config-pattern
Adds the ability to add and update configuration/settings
- Loading branch information
Showing
11 changed files
with
399 additions
and
150 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
minimal_redux_poc/__tests__/integration/mirador/config_updating_from_instance.test.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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* global miradorInstance */ | ||
|
||
describe('Config updating from instance', () => { | ||
beforeAll(async () => { | ||
await page.goto('http://127.0.0.1:4488/__tests__/integration/mirador/'); | ||
}); | ||
it('can modify the config via api', async () => { | ||
await page.evaluate(() => { | ||
const a = miradorInstance.actions.updateConfig({ foo: 'bat' }); | ||
miradorInstance.store.dispatch(a); | ||
}); | ||
const config = await page.evaluate(() => ( | ||
miradorInstance.store.getState().config | ||
)); | ||
await expect(config.foo).toBe('bat'); | ||
}); | ||
}); |
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,42 @@ | ||
import reducer from '../../../src/reducers/config'; | ||
import ActionTypes from '../../../src/action-types'; | ||
|
||
describe('config reducer', () => { | ||
describe('SET_CONFIG', () => { | ||
it('should handle SET_CONFIG', () => { | ||
expect(reducer({}, { | ||
type: ActionTypes.SET_CONFIG, | ||
config: { manifestVersion: 'v3' }, | ||
})).toEqual({ | ||
manifestVersion: 'v3', | ||
}); | ||
}); | ||
it('does not deep merge', () => { | ||
expect(reducer({ stuff: { foo: 'bar' } }, { | ||
type: ActionTypes.SET_CONFIG, | ||
config: { stuff: { foo: 'bat' } }, | ||
})).toEqual({ | ||
stuff: { foo: 'bat' }, | ||
}); | ||
}); | ||
}); | ||
describe('UPDATE_CONFIG', () => { | ||
it('should handle UPDATE_CONFIG', () => { | ||
expect(reducer({}, { | ||
type: ActionTypes.UPDATE_CONFIG, | ||
config: { manifestVersion: 'v3' }, | ||
})).toEqual({ | ||
manifestVersion: 'v3', | ||
}); | ||
}); | ||
it('does a deep merge', () => { | ||
expect(reducer({ stuff: { foo: 'bar' }, hello: 'world' }, { | ||
type: ActionTypes.UPDATE_CONFIG, | ||
config: { stuff: { foo: 'bat' } }, | ||
})).toEqual({ | ||
stuff: { foo: 'bat' }, | ||
hello: 'world', | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.