2019-02-16 11:04:55 +01:00
|
|
|
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'
|
2019-06-06 16:44:50 +02:00
|
|
|
import { LocalTag } from '~/src/types/localTag'
|
2020-03-15 09:48:02 +01:00
|
|
|
import { Entity } from 'megalodon'
|
2019-02-16 11:04:55 +01:00
|
|
|
|
|
|
|
describe('TimelineSpace/Modals/Jump', () => {
|
|
|
|
describe('mutations', () => {
|
2019-04-09 16:15:15 +02:00
|
|
|
let state: JumpState
|
2019-02-16 11:04:55 +01:00
|
|
|
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',
|
2019-04-10 13:58:11 +02:00
|
|
|
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',
|
2019-04-10 13:58:11 +02:00
|
|
|
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',
|
2019-04-10 13:58:11 +02:00
|
|
|
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])
|
2019-02-16 11:04:55 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('updateTagChannel', () => {
|
|
|
|
it('should be updated', () => {
|
2019-04-16 14:44:46 +02:00
|
|
|
const whalebird: LocalTag = {
|
2019-04-09 16:15:15 +02:00
|
|
|
tagName: 'whalebird'
|
|
|
|
}
|
2019-04-16 14:44:46 +02:00
|
|
|
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])
|
2019-02-16 11:04:55 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|