Whalebird-desktop-client-ma.../spec/renderer/unit/store/TimelineSpace/Modals/Jump.spec.ts

111 lines
3.0 KiB
TypeScript
Raw Normal View History

import i18n from '~/src/config/i18n'
2019-04-09 16:15:15 +02:00
import Jump, { JumpState, MUTATION_TYPES, Channel } from '@/store/TimelineSpace/Modals/Jump'
import { LocalTag } from '~/src/types/localTag'
2020-03-15 09:48:02 +01:00
import { Entity } from 'megalodon'
describe('TimelineSpace/Modals/Jump', () => {
describe('mutations', () => {
2019-04-09 16:15:15 +02:00
let state: JumpState
beforeEach(() => {
state = {
modalOpen: true,
channel: '',
defaultChannelList: [
{
name: i18n.t('side_menu.home'),
path: 'home'
},
{
name: i18n.t('side_menu.notification'),
path: 'notifications'
},
{
name: i18n.t('side_menu.favourite'),
path: 'favourites'
},
{
name: i18n.t('side_menu.local'),
path: 'local'
},
{
name: i18n.t('side_menu.public'),
path: 'public'
},
{
name: i18n.t('side_menu.hashtag'),
path: 'hashtag'
},
{
name: i18n.t('side_menu.search'),
path: 'search'
},
{
name: i18n.t('side_menu.direct'),
path: 'direct-messages'
}
],
listChannelList: [],
tagChannelList: [],
selectedChannel: {
name: i18n.t('side_menu.home'),
path: 'home'
}
}
})
describe('updateListChannel', () => {
it('should be updated', () => {
2020-03-15 09:48:02 +01:00
const admin: Entity.List = {
2019-05-27 16:04:53 +02:00
id: '0',
title: 'admin'
2019-04-09 16:15:15 +02:00
}
2020-03-15 09:48:02 +01:00
const engineer: Entity.List = {
2019-05-27 16:04:53 +02:00
id: '1',
title: 'engineer'
2019-04-09 16:15:15 +02:00
}
2020-03-15 09:48:02 +01:00
const designer: Entity.List = {
2019-05-27 16:04:53 +02:00
id: '2',
title: 'designer'
2019-04-09 16:15:15 +02:00
}
const channelList = [admin, engineer, designer]
Jump.mutations![MUTATION_TYPES.UPDATE_LIST_CHANNEL](state, channelList)
const adminChannel: Channel = {
path: 'lists/0',
name: '#admin'
}
const engineerChannel: Channel = {
path: 'lists/1',
name: '#engineer'
}
const designerChannel: Channel = {
path: 'lists/2',
name: '#designer'
}
expect(state.listChannelList).toEqual([adminChannel, engineerChannel, designerChannel])
})
})
describe('updateTagChannel', () => {
it('should be updated', () => {
const whalebird: LocalTag = {
2019-04-09 16:15:15 +02:00
tagName: 'whalebird'
}
const tqrk: LocalTag = {
2019-04-09 16:15:15 +02:00
tagName: 'tqrk'
}
const channelList = [whalebird, tqrk]
Jump.mutations![MUTATION_TYPES.UPDATE_TAG_CHANNEL](state, channelList)
const whalebirdChannel: Channel = {
name: '#whalebird',
path: 'hashtag/whalebird'
}
const tqrkChannel: Channel = {
name: '#tqrk',
path: 'hashtag/tqrk'
}
expect(state.tagChannelList).toEqual([whalebirdChannel, tqrkChannel])
})
})
})
})