From da93525d2e1922ed393e6f273e7df1226768df12 Mon Sep 17 00:00:00 2001 From: Matthew Shao Date: Fri, 10 Mar 2017 08:52:11 +0800 Subject: [web] remove the tests for abandoned files. --- web/src/js/__tests__/ducks/flowViewSpec.js | 67 ------------ web/src/js/__tests__/ducks/utils/listSpec.js | 64 ----------- web/src/js/__tests__/ducks/utils/viewSpec.js | 156 --------------------------- 3 files changed, 287 deletions(-) delete mode 100644 web/src/js/__tests__/ducks/flowViewSpec.js delete mode 100644 web/src/js/__tests__/ducks/utils/listSpec.js delete mode 100644 web/src/js/__tests__/ducks/utils/viewSpec.js diff --git a/web/src/js/__tests__/ducks/flowViewSpec.js b/web/src/js/__tests__/ducks/flowViewSpec.js deleted file mode 100644 index d5d9a6d9..00000000 --- a/web/src/js/__tests__/ducks/flowViewSpec.js +++ /dev/null @@ -1,67 +0,0 @@ -jest.unmock('../../ducks/flows') -jest.unmock('../../ducks/flowView') -jest.unmock('../../ducks/utils/view') -jest.unmock('../../ducks/utils/list') -jest.unmock('./tutils') - -import { createStore } from './tutils' - -import flows, * as flowActions from '../../ducks/flows' -import flowView, * as flowViewActions from '../../ducks/flowView' - - -function testStore() { - let store = createStore({ - flows, - flowView - }) - for (let i of [1, 2, 3, 4]) { - store.dispatch( - flowActions.addFlow({ id: i }) - ) - } - return store -} - -describe('select relative', () => { - - function testSelect(start, relative, result) { - const store = testStore() - store.dispatch(flowActions.select(start)) - expect(store.getState().flows.selected).toEqual(start ? [start] : []) - store.dispatch(flowViewActions.selectRelative(relative)) - expect(store.getState().flows.selected).toEqual([result]) - } - - describe('previous', () => { - - it('should select the previous flow', () => { - testSelect(3, -1, 2) - }) - - it('should not changed when first flow is selected', () => { - testSelect(1, -1, 1) - }) - - it('should select first flow if no flow is selected', () => { - testSelect(undefined, -1, 1) - }) - - }) - - describe('next', () => { - - it('should select the next flow', () => { - testSelect(2, 1, 3) - }) - - it('should not changed when last flow is selected', () => { - testSelect(4, 1, 4) - }) - - it('should select last flow if no flow is selected', () => { - testSelect(undefined, 1, 4) - }) - - }) -}) diff --git a/web/src/js/__tests__/ducks/utils/listSpec.js b/web/src/js/__tests__/ducks/utils/listSpec.js deleted file mode 100644 index 0f5d0f34..00000000 --- a/web/src/js/__tests__/ducks/utils/listSpec.js +++ /dev/null @@ -1,64 +0,0 @@ -jest.unmock('lodash') -jest.unmock('../../../ducks/utils/list') - -import reduce, * as list from '../../../ducks/utils/list' -import _ from 'lodash' - -describe('list reduce', () => { - - it('should add item', () => { - const state = createState([ - { id: 1 }, - { id: 2 } - ]) - const result = createState([ - { id: 1 }, - { id: 2 }, - { id: 3 } - ]) - expect(reduce(state, list.add({ id: 3 }))).toEqual(result) - }) - - it('should update item', () => { - const state = createState([ - { id: 1, val: 1 }, - { id: 2, val: 2 } - ]) - const result = createState([ - { id: 1, val: 1 }, - { id: 2, val: 3 } - ]) - expect(reduce(state, list.update({ id: 2, val: 3 }))).toEqual(result) - }) - - it('should remove item', () => { - const state = createState([ - { id: 1 }, - { id: 2 } - ]) - const result = createState([ - { id: 1 } - ]) - result.byId[2] = result.indexOf[2] = null - expect(reduce(state, list.remove(2))).toEqual(result) - }) - - it('should replace all items', () => { - const state = createState([ - { id: 1 }, - { id: 2 } - ]) - const result = createState([ - { id: 1 } - ]) - expect(reduce(state, list.receive([{ id: 1 }]))).toEqual(result) - }) -}) - -function createState(items) { - return { - data: items, - byId: _.fromPairs(items.map((item, index) => [item.id, item])), - indexOf: _.fromPairs(items.map((item, index) => [item.id, index])) - } -} diff --git a/web/src/js/__tests__/ducks/utils/viewSpec.js b/web/src/js/__tests__/ducks/utils/viewSpec.js deleted file mode 100644 index af3da173..00000000 --- a/web/src/js/__tests__/ducks/utils/viewSpec.js +++ /dev/null @@ -1,156 +0,0 @@ -jest.unmock('../../../ducks/utils/view') -jest.unmock('lodash') - -import reduce, * as view from '../../../ducks/utils/view' -import _ from 'lodash' - -describe('view reduce', () => { - - it('should filter items', () => { - const state = createState([ - { id: 1 }, - { id: 2 } - ]) - const result = createState([ - { id: 1 } - ]) - expect(reduce(state, view.updateFilter(state.data, item => item.id === 1))).toEqual(result) - }) - - it('should sort items', () => { - const state = createState([ - { id: 1 }, - { id: 2 } - ]) - const result = createState([ - { id: 2 }, - { id: 1 } - ]) - expect(reduce(state, view.updateSort((a, b) => b.id - a.id))).toEqual(result) - }) - - it('should add item', () => { - const state = createState([ - { id: 1 }, - { id: 2 } - ]) - const result = createState([ - { id: 1 }, - { id: 2 }, - { id: 3 } - ]) - expect(reduce(state, view.add({ id: 3 }))).toEqual(result) - }) - - it('should add item in place', () => { - const state = createState([ - { id: 1 } - ]) - const result = createState([ - { id: 3 }, - { id: 1 } - ]) - expect(reduce(state, view.add({ id: 3 }, undefined, (a, b) => b.id - a.id))).toEqual(result) - }) - - it('should filter added item', () => { - const state = createState([ - { id: 1 } - ]) - const result = createState([ - { id: 1 } - ]) - expect(reduce(state, view.add({ id: 3 }, i => i.id === 1))).toEqual(result) - }) - - it('should update item', () => { - const state = createState([ - { id: 1, val: 1 }, - { id: 2, val: 2 }, - { id: 3, val: 3 } - ]) - const result = createState([ - { id: 1, val: 1 }, - { id: 2, val: 3 }, - { id: 3, val: 3 } - ]) - expect(reduce(state, view.update({ id: 2, val: 3 }))).toEqual(result) - }) - - it('should sort updated item', () => { - const state = createState([ - { id: 1, val: 1 }, - { id: 2, val: 2 } - ]) - const result = createState([ - { id: 2, val: 3 }, - { id: 1, val: 1 } - ]) - expect(reduce(state, view.update({ id: 2, val: 3 }, undefined, (a, b) => b.id - a.id))).toEqual(result) - }) - - it('should filter updated item', () => { - const state = createState([ - { id: 1, val: 1 }, - { id: 2, val: 2 } - ]) - const result = createState([ - { id: 1, val: 1 } - ]) - result.indexOf[2] = null - expect(reduce(state, view.update({ id: 2, val: 3 }, i => i.id === i.val))).toEqual(result) - }) - - it('should remove item', () => { - const state = createState([ - { id: 1 }, - { id: 2 } - ]) - const result = createState([ - { id: 1 } - ]) - result.indexOf[2] = null - expect(reduce(state, view.remove(2))).toEqual(result) - }) - - it('should replace items', () => { - const state = createState([ - { id: 1 }, - { id: 2 } - ]) - const result = createState([ - { id: 1 } - ]) - expect(reduce(state, view.receive([{ id: 1 }]))).toEqual(result) - }) - - it('should sort received items', () => { - const state = createState([ - { id: 1 }, - { id: 2 } - ]) - const result = createState([ - { id: 2 }, - { id: 1 } - ]) - expect(reduce(state, view.receive([{ id: 1 }, { id: 2 }], undefined, (a, b) => b.id - a.id))).toEqual(result) - }) - - it('should filter received', () => { - const state = createState([ - { id: 1 }, - { id: 2 } - ]) - const result = createState([ - { id: 1 } - ]) - expect(reduce(state, view.receive([{ id: 1 }, { id: 2 }], i => i.id === 1))).toEqual(result) - }) -}) - -function createState(items) { - return { - data: items, - indexOf: _.fromPairs(items.map((item, index) => [item.id, index])) - } -} -- cgit v1.2.3