[web] remove the tests for abandoned files.

This commit is contained in:
Matthew Shao 2017-03-10 08:52:11 +08:00
parent 98b5893855
commit da93525d2e
3 changed files with 0 additions and 287 deletions

View File

@ -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)
})
})
})

View File

@ -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]))
}
}

View File

@ -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]))
}
}