Skip to content

Commit

Permalink
U
Browse files Browse the repository at this point in the history
  • Loading branch information
joehecn committed Jul 28, 2018
1 parent 01e5fe4 commit 25702e4
Showing 1 changed file with 96 additions and 55 deletions.
151 changes: 96 additions & 55 deletions __tests__/worker/data.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@

import data from '@/worker/data.js'

const dataGetListMB = () => {
return data.getListMB({
tos: {
'Mbf403351dfb2ae819874163aff25a49c': {
NickName: 'a',
RemarkName: ''
},
'Mbf40335': {
NickName: 'aa',
RemarkName: ''
},
'Bbf40335': {
NickName: 'aaa',
RemarkName: ''
}
}
})
}

describe('worker/data.js', () => {
beforeEach(() => {
data.addChatListAndRepeatList([
Expand All @@ -10,19 +29,19 @@ describe('worker/data.js', () => {
{ NickName: 'jjjoe', UserName: '@@jjjoehe', RemarkName: '' }
])
})

afterEach(() => {
data.resetData()
})

test('addChatListAndRepeatList', () => {
expect.assertions(2)

const count = data.getChatListCount()
const repeatNameList = data.getRepeatNameList()

expect(count).toBe(2)
expect(repeatNameList).toEqual([ 'joe' ])
expect(repeatNameList).toEqual(['joe'])
})

test('getNickName', () => {
Expand All @@ -33,69 +52,87 @@ describe('worker/data.js', () => {

test('getListMB', () => {
expect.assertions(1)
const list = data.getListMB({
tos: {
'Mbf403351dfb2ae819874163aff25a49c': {
NickName: 'a',
RemarkName: ''
},
'Mbf40335': {
NickName: 'aa',
RemarkName: ''
},
'Bbf40335': {
NickName: 'aaa',
RemarkName: ''
}
}
// const list = data.getListMB({
// tos: {
// 'Mbf403351dfb2ae819874163aff25a49c': {
// NickName: 'a',
// RemarkName: ''
// },
// 'Mbf40335': {
// NickName: 'aa',
// RemarkName: ''
// },
// 'Bbf40335': {
// NickName: 'aaa',
// RemarkName: ''
// }
// }
// })
const list = dataGetListMB()

expect(list).toEqual({
listM: [{
premd5: 'Mbf403351dfb2ae819874163aff25a49c',
NickName: 'joe1',
RemarkName: '',
status: 1
}, {
premd5: 'Mbf40335',
NickName: 'aa',
RemarkName: '',
status: 3
}],
listB: [{
premd5: 'B120b1df75e335bb5bedbc198c53b4fe9',
NickName: 'jjjoe',
RemarkName: '',
status: 2
}, {
premd5: 'Bbf40335',
NickName: 'aaa',
RemarkName: '',
status: 3
}]
})

expect(list).toEqual({ listM:
[ { premd5: 'Mbf403351dfb2ae819874163aff25a49c',
NickName: 'joe1',
RemarkName: '',
status: 1 },
{ premd5: 'Mbf40335', NickName: 'aa', RemarkName: '', status: 3 } ],
listB:
[ { premd5: 'B120b1df75e335bb5bedbc198c53b4fe9',
NickName: 'jjjoe',
RemarkName: '',
status: 2 },
{ premd5: 'Bbf40335', NickName: 'aaa', RemarkName: '', status: 3 } ] })
})

test('setCurGroup', () => {
expect.assertions(2)

data.getListMB({
tos: {
'Mbf403351dfb2ae819874163aff25a49c': {
NickName: 'a',
RemarkName: ''
},
'Mbf40335': {
NickName: 'aa',
RemarkName: ''
},
'Bbf40335': {
NickName: 'aaa',
RemarkName: ''
}
}
})

// data.getListMB({
// tos: {
// 'Mbf403351dfb2ae819874163aff25a49c': {
// NickName: 'a',
// RemarkName: ''
// },
// 'Mbf40335': {
// NickName: 'aa',
// RemarkName: ''
// },
// 'Bbf40335': {
// NickName: 'aaa',
// RemarkName: ''
// }
// }
// })
dataGetListMB()

let curGroup = data.setCurGroup({
status: 3,
premd5: '1234',
NickName: 'aa',
RemarkName: ''
})

expect(curGroup).toEqual({ tos:
{ '1234': { NickName: 'aa', RemarkName: '' },
expect(curGroup).toEqual({
tos:
{
'1234': { NickName: 'aa', RemarkName: '' },
Mbf403351dfb2ae819874163aff25a49c: { NickName: 'a', RemarkName: '' },
Mbf40335: { NickName: 'aa', RemarkName: '' },
Bbf40335: { NickName: 'aaa', RemarkName: '' } } })
Bbf40335: { NickName: 'aaa', RemarkName: '' }
}
})

curGroup = data.setCurGroup({
status: 1,
Expand All @@ -104,15 +141,19 @@ describe('worker/data.js', () => {
RemarkName: ''
})

expect(curGroup).toEqual({ tos:
{ Mbf403351dfb2ae819874163aff25a49c: { NickName: 'a', RemarkName: '' },
expect(curGroup).toEqual({
tos:
{
Mbf403351dfb2ae819874163aff25a49c: { NickName: 'a', RemarkName: '' },
Mbf40335: { NickName: 'aa', RemarkName: '' },
Bbf40335: { NickName: 'aaa', RemarkName: '' } } })
Bbf40335: { NickName: 'aaa', RemarkName: '' }
}
})
})

test('getToList', () => {
expect.assertions(1)

const list = data.getToList({
'Mbf403351dfb2ae819874163aff25a49c': 0
})
Expand Down

0 comments on commit 25702e4

Please sign in to comment.