aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--web/package.json2
-rw-r--r--web/src/js/__tests__/ducks/eventLogSpec.js40
2 files changed, 41 insertions, 1 deletions
diff --git a/web/package.json b/web/package.json
index 601d7077..f0b3ae6a 100644
--- a/web/package.json
+++ b/web/package.json
@@ -8,7 +8,7 @@
},
"jest": {
"testRegex": "__tests__/.*Spec.js$",
- "testPathDirs": [
+ "roots": [
"<rootDir>/src/js"
],
"unmockedModulePathPatterns": [
diff --git a/web/src/js/__tests__/ducks/eventLogSpec.js b/web/src/js/__tests__/ducks/eventLogSpec.js
new file mode 100644
index 00000000..d4d4f37a
--- /dev/null
+++ b/web/src/js/__tests__/ducks/eventLogSpec.js
@@ -0,0 +1,40 @@
+jest.unmock('../../ducks/eventLog')
+
+import reduceEventLog, * as eventLogActions from '../../ducks/eventLog'
+import reduceStore from '../../ducks/utils/store'
+
+describe('event log reducer', () => {
+ it('should return initial state', () => {
+ expect(reduceEventLog(undefined, {})).toEqual({
+ visible: false,
+ filters: { debug: false, info: true, web: true, warn: true, error: true },
+ ...reduceStore(undefined, {}),
+ })
+ })
+
+ it('should be possible to toggle filter', () => {
+ let state = reduceEventLog(undefined, eventLogActions.add('foo'))
+ expect(reduceEventLog(state, eventLogActions.toggleFilter('info'))).toEqual({
+ visible: false,
+ filters: { ...state.filters, info: false},
+ ...reduceStore(state, {})
+ })
+ })
+
+ it('should be possible to toggle visibility', () => {
+ let state = reduceEventLog(undefined, {})
+ expect(reduceEventLog(state, eventLogActions.toggleVisibility())).toEqual({
+ visible: true,
+ filters: {...state.filters},
+ ...reduceStore(undefined, {})
+ })
+ })
+
+ it('should be possible to add message', () => {
+ let state = reduceEventLog(undefined, eventLogActions.add('foo'))
+ expect(state.visible).toBeFalsy()
+ expect(state.filters).toEqual({
+ debug: false, info: true, web: true, warn: true, error: true
+ })
+ })
+})