-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
Fm.test.js
62 lines (58 loc) · 1.76 KB
/
Fm.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import fmReducer from '../reducers/fm'
const typeSpecs = [
['PLAYLIST_NEW_REQUEST', 'n'],
['PLAYLIST_PLAYING_REQUEST', 'p'],
['PLAYLIST_SKIP_REQUEST', 's'],
['PLAYLIST_TRASH_REQUEST', 'b'],
['RED_HEART_RATE', 'r'],
['RED_HEART_UNRATE', 'u'],
['PLAYLIST_END_REQUEST', 'e']
]
describe('fmReducer', () => {
// loading test
test('fetching', () => {
expect(fmReducer({ isFetching: false }, { type: 'PLAYLIST_LOADING' })).toEqual({ isFetching: true })
})
test('end fetching', () => {
expect(fmReducer({ isFetching: true }, { type: 'PLAYLIST_RESPONSE' })).toEqual({ isFetching: false })
})
// type test
test('new', () => {
typeSpecs.map(t => expect(fmReducer({ type: '' }, { type: t[0] })).toEqual({ type: t[1] }))
})
// pattern test
test('select pattern', () => {
expect(fmReducer({ pattern: '' }, { type: 'SELECT_PATTERN' })).toEqual({
pattern: 'select',
channelId: -10
})
})
test('recent pattern', () => {
expect(
fmReducer(
{
pattern: 'select',
recent: { songs: [{ sid: 'mock', ssid: 'mock' }] }
},
{ type: 'RECENT_PATTERN' }
)
).toHaveProperty('pattern', 'recent')
expect(
fmReducer(
{
pattern: 'select',
recent: { songs: [{ sid: 'mock', ssid: 'mock' }] }
},
{ type: 'RECENT_PATTERN' }
)
).toHaveProperty('songListIndex', 0)
})
test('redheart pattern', () => {
expect(
fmReducer({ pattern: 'select', redheart: [{ sid: 'mock', ssid: 'mock' }] }, { type: 'REDHEART_PATTERN' })
).toHaveProperty('pattern', 'redheart')
expect(
fmReducer({ pattern: 'select', redheart: [{ sid: 'mock', ssid: 'mock' }] }, { type: 'REDHEART_PATTERN' })
).toHaveProperty('songListIndex', 0)
})
})