diff --git a/webapp/components/Paginate/Paginate.spec.js b/webapp/components/Paginate/Paginate.spec.js new file mode 100644 index 000000000..36e22d1b4 --- /dev/null +++ b/webapp/components/Paginate/Paginate.spec.js @@ -0,0 +1,71 @@ +import { mount, createLocalVue } from '@vue/test-utils' +import Styleguide from '@human-connection/styleguide' +import Paginate from './Paginate' + +const localVue = createLocalVue() + +localVue.use(Styleguide) + +describe('Paginate.vue', () => { + let propsData, wrapper, Wrapper, nextButton, backButton + + beforeEach(() => { + propsData = {} + }) + + Wrapper = () => { + return mount(Paginate, { propsData, localVue }) + } + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + describe('next button', () => { + beforeEach(() => { + propsData.hasNext = true + wrapper = Wrapper() + nextButton = wrapper.findAll('.ds-button').at(0) + }) + + it('is disabled by default', () => { + propsData = {} + wrapper = Wrapper() + nextButton = wrapper.findAll('.ds-button').at(0) + expect(nextButton.attributes().disabled).toEqual('disabled') + }) + + it('is not disabled if hasNext is true', () => { + expect(nextButton.attributes().disabled).toBeUndefined() + }) + + it('emits back when clicked', async () => { + await nextButton.trigger('click') + expect(wrapper.emitted().next).toHaveLength(1) + }) + }) + + describe('back button', () => { + beforeEach(() => { + propsData.hasPrevious = true + wrapper = Wrapper() + backButton = wrapper.findAll('.ds-button').at(1) + }) + + it('is disabled by default', () => { + propsData = {} + wrapper = Wrapper() + backButton = wrapper.findAll('.ds-button').at(1) + expect(backButton.attributes().disabled).toEqual('disabled') + }) + + it('is not disabled if hasPrevious is true', () => { + expect(backButton.attributes().disabled).toBeUndefined() + }) + + it('emits back when clicked', async () => { + await backButton.trigger('click') + expect(wrapper.emitted().back).toHaveLength(1) + }) + }) + }) +}) diff --git a/webapp/components/Paginate/Paginate.vue b/webapp/components/Paginate/Paginate.vue new file mode 100644 index 000000000..aa1455d19 --- /dev/null +++ b/webapp/components/Paginate/Paginate.vue @@ -0,0 +1,26 @@ + + diff --git a/webapp/graphql/User.js b/webapp/graphql/User.js index 5a4b18b6a..7b2a012a4 100644 --- a/webapp/graphql/User.js +++ b/webapp/graphql/User.js @@ -51,8 +51,8 @@ export const notificationQuery = i18n => { ${commentFragment(lang)} ${postFragment(lang)} - query($read: Boolean, $orderBy: NotificationOrdering) { - notifications(read: $read, orderBy: $orderBy) { + query($read: Boolean, $orderBy: NotificationOrdering, $first: Int, $offset: Int) { + notifications(read: $read, orderBy: $orderBy, first: $first, offset: $offset) { read reason createdAt diff --git a/webapp/pages/notifications/index.vue b/webapp/pages/notifications/index.vue index 95d30df1a..5d22aa0b4 100644 --- a/webapp/pages/notifications/index.vue +++ b/webapp/pages/notifications/index.vue @@ -5,158 +5,52 @@ {{ $t('notifications.title') }} - - - - {{ selected }} - - - - - {{ item.route.label }} - - - + + + - - - - - - - + +