Skip to content

Commit

Permalink
补全测试
Browse files Browse the repository at this point in the history
  • Loading branch information
Darmody committed Apr 13, 2017
1 parent ebe30e6 commit beeb255
Show file tree
Hide file tree
Showing 32 changed files with 505 additions and 1,080 deletions.
3 changes: 3 additions & 0 deletions __mocks__/electron.js
@@ -0,0 +1,3 @@
export const ipcRenderer = {
on: fn => fn,
}
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -112,7 +112,10 @@
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js"
}
},
"coveragePathIgnorePatterns": [
"src/components/Icons"
]
},
"moduleRoots": [
"src"
Expand Down
14 changes: 14 additions & 0 deletions src/actions/__tests__/__snapshots__/auth.test.js.snap
@@ -1,5 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`action::auth 创建一个登出 action 1`] = `
Object {
"payload": undefined,
"type": "LOGOUT",
}
`;

exports[`action::auth 创建一个登录 action 1`] = `
Object {
"payload": Object {
Expand All @@ -18,3 +25,10 @@ Object {
"type": "LOGIN/SUCCESS",
}
`;

exports[`action::auth 创建一个认证 action 1`] = `
Object {
"payload": undefined,
"type": "AUTH/REQUEST",
}
`;
30 changes: 30 additions & 0 deletions src/actions/__tests__/__snapshots__/entities.test.js.snap
@@ -0,0 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`action::entities 创建一个保存 entities action 1`] = `
Object {
"payload": Object {
"user": Object {
"1": Object {
"id": 1,
},
},
},
"type": "ENTITIES/SAVE",
}
`;

exports[`action::entities 创建一个更新 entity 字段 action 1`] = `
Object {
"payload": Array [
Object {
"field": Array [
"users",
"1",
"id",
],
"value": 2,
},
],
"type": "ENTITIES/UPDATE",
}
`;
77 changes: 77 additions & 0 deletions src/actions/__tests__/__snapshots__/songs.test.js.snap
@@ -0,0 +1,77 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`action::songs 创建一个 ban action 1`] = `
Object {
"payload": Object {
"channel": 1,
"sid": 2,
},
"type": "SONGS/BAN/REQUEST",
}
`;

exports[`action::songs 创建一个 current action 1`] = `
Object {
"payload": Object {
"sid": 1,
},
"type": "SONGS/CURRENT",
}
`;

exports[`action::songs 创建一个 dislike action 1`] = `
Object {
"payload": Object {
"channel": 1,
"sid": 2,
},
"type": "SONGS/DISLIKE/REQUEST",
}
`;

exports[`action::songs 创建一个 like action 1`] = `
Object {
"payload": Object {
"channel": 1,
"sid": 2,
},
"type": "SONGS/LIKE/REQUEST",
}
`;

exports[`action::songs 创建一个 listen action 1`] = `
Object {
"payload": 1,
"type": "SONGS/LISTEN/REQUEST",
}
`;

exports[`action::songs 创建一个 mark action 1`] = `
Object {
"payload": Object {
"channel": 1,
"sid": 2,
},
"type": "SONGS/MARK/REQUEST",
}
`;

exports[`action::songs 创建一个 next action 1`] = `
Object {
"payload": Object {
"channel": 1,
"sid": 2,
},
"type": "SONGS/NEXT/REQUEST",
}
`;

exports[`action::songs 创建一个 playedList action 1`] = `
Object {
"payload": Object {
"limit": 10,
"start": 0,
},
"type": "SONGS/PLAYED/REQUEST",
}
`;
8 changes: 8 additions & 0 deletions src/actions/__tests__/__snapshots__/users.test.js.snap
@@ -0,0 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`action::users 创建一个 current action 1`] = `
Object {
"payload": undefined,
"type": "USER/CURRENT/REQUEST",
}
`;
8 changes: 8 additions & 0 deletions src/actions/__tests__/auth.test.js
Expand Up @@ -8,4 +8,12 @@ describe('action::auth', () => {
it('创建一个登录成功的 action', () => {
expect(actions.logined({ access_token: 'token' })).toMatchSnapshot()
})

it('创建一个登出 action', () => {
expect(actions.logout()).toMatchSnapshot()
})

it('创建一个认证 action', () => {
expect(actions.auth()).toMatchSnapshot()
})
})
15 changes: 15 additions & 0 deletions src/actions/__tests__/entities.test.js
@@ -0,0 +1,15 @@
import * as actions from '../entities'

describe('action::entities', () => {
it('创建一个保存 entities action', () => {
expect(actions.save({
user: { 1: { id: 1 } }
})).toMatchSnapshot()
})

it('创建一个更新 entity 字段 action', () => {
expect(actions.update([{
field: ['users', '1', 'id'], value: 2,
}])).toMatchSnapshot()
})
})
35 changes: 35 additions & 0 deletions src/actions/__tests__/songs.test.js
@@ -0,0 +1,35 @@
import * as actions from '../songs'

describe('action::songs', () => {
it('创建一个 ban action', () => {
expect(actions.ban(1, 2)).toMatchSnapshot()
})

it('创建一个 current action', () => {
expect(actions.current({ sid: 1 })).toMatchSnapshot()
})

it('创建一个 like action', () => {
expect(actions.like(1, 2)).toMatchSnapshot()
})

it('创建一个 dislike action', () => {
expect(actions.dislike(1, 2)).toMatchSnapshot()
})

it('创建一个 listen action', () => {
expect(actions.listen(1)).toMatchSnapshot()
})

it('创建一个 next action', () => {
expect(actions.next(1, 2)).toMatchSnapshot()
})

it('创建一个 mark action', () => {
expect(actions.mark(1, 2)).toMatchSnapshot()
})

it('创建一个 playedList action', () => {
expect(actions.playedList(0, 10)).toMatchSnapshot()
})
})
7 changes: 7 additions & 0 deletions src/actions/__tests__/users.test.js
@@ -0,0 +1,7 @@
import * as actions from '../users'

describe('action::users', () => {
it('创建一个 current action', () => {
expect(actions.current()).toMatchSnapshot()
})
})
12 changes: 0 additions & 12 deletions src/components/Body/__tests__/Body.test.js

This file was deleted.

0 comments on commit beeb255

Please sign in to comment.