mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Display and test notification counter
This commit is contained in:
parent
edfbd2a6ed
commit
5b77c92c35
@ -8,50 +8,20 @@ const localVue = createLocalVue()
|
|||||||
localVue.use(Styleguide)
|
localVue.use(Styleguide)
|
||||||
localVue.filter('truncate', string => string)
|
localVue.filter('truncate', string => string)
|
||||||
|
|
||||||
config.stubs['dropdown'] = '<span><slot /></span>'
|
config.stubs['dropdown'] = '<span class="dropdown"><slot /></span>'
|
||||||
|
|
||||||
describe('NotificationMenu.vue', () => {
|
describe('NotificationMenu.vue', () => {
|
||||||
let wrapper
|
let wrapper
|
||||||
let Wrapper
|
let Wrapper
|
||||||
let mocks
|
let mocks
|
||||||
let data
|
let data
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mocks = {
|
mocks = {
|
||||||
$t: jest.fn()
|
$t: jest.fn()
|
||||||
}
|
}
|
||||||
data = () => {
|
data = () => {
|
||||||
return {
|
return {
|
||||||
notifications: [
|
notifications: []
|
||||||
{
|
|
||||||
id: 'notification-41',
|
|
||||||
read: false,
|
|
||||||
post: {
|
|
||||||
id: 'post-1',
|
|
||||||
title: 'some post title',
|
|
||||||
contentExcerpt: 'this is a post content',
|
|
||||||
author: {
|
|
||||||
id: 'john-1',
|
|
||||||
slug: 'john-doe',
|
|
||||||
name: 'John Doe'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'notification-42',
|
|
||||||
read: false,
|
|
||||||
post: {
|
|
||||||
id: 'post-2',
|
|
||||||
title: 'another post title',
|
|
||||||
contentExcerpt: 'this is yet another post content',
|
|
||||||
author: {
|
|
||||||
id: 'john-1',
|
|
||||||
slug: 'john-doe',
|
|
||||||
name: 'John Doe'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -65,12 +35,58 @@ describe('NotificationMenu.vue', () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
it('counter displays 0', () => {
|
||||||
wrapper = Wrapper()
|
wrapper = Wrapper()
|
||||||
|
expect(wrapper.find('ds-button-stub').text()).toEqual('0')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('displays the total number of notifications', () => {
|
it('no dropdown is rendered', () => {
|
||||||
expect(wrapper.find('ds-button-stub').text()).toEqual('2')
|
wrapper = Wrapper()
|
||||||
|
expect(wrapper.contains('.dropdown')).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('given some notifications', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
data = () => {
|
||||||
|
return {
|
||||||
|
notifications: [
|
||||||
|
{
|
||||||
|
id: 'notification-41',
|
||||||
|
read: false,
|
||||||
|
post: {
|
||||||
|
id: 'post-1',
|
||||||
|
title: 'some post title',
|
||||||
|
contentExcerpt: 'this is a post content',
|
||||||
|
author: {
|
||||||
|
id: 'john-1',
|
||||||
|
slug: 'john-doe',
|
||||||
|
name: 'John Doe'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'notification-42',
|
||||||
|
read: false,
|
||||||
|
post: {
|
||||||
|
id: 'post-2',
|
||||||
|
title: 'another post title',
|
||||||
|
contentExcerpt: 'this is yet another post content',
|
||||||
|
author: {
|
||||||
|
id: 'john-1',
|
||||||
|
slug: 'john-doe',
|
||||||
|
name: 'John Doe'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('displays the total number of notifications', () => {
|
||||||
|
wrapper = Wrapper()
|
||||||
|
expect(wrapper.find('ds-button-stub').text()).toEqual('2')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,5 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<dropdown class="notifications-menu">
|
<ds-button
|
||||||
|
v-if="totalNotifications <= 0"
|
||||||
|
disabled
|
||||||
|
icon="bell"
|
||||||
|
>
|
||||||
|
{{ totalNotifications }}
|
||||||
|
</ds-button>
|
||||||
|
<dropdown
|
||||||
|
v-else
|
||||||
|
class="notifications-menu"
|
||||||
|
>
|
||||||
<template
|
<template
|
||||||
slot="default"
|
slot="default"
|
||||||
slot-scope="{toggleMenu}"
|
slot-scope="{toggleMenu}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user