From b1bc46e170a1e76fd58f51b52d1e42a723b9c9be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Sun, 10 Mar 2019 03:04:45 +0100 Subject: [PATCH] DisableModal ready --- components/Modal/DisableModal.spec.js | 63 ++++++++++++++++++++++++--- components/Modal/DisableModal.vue | 51 +++++++++++++++++----- 2 files changed, 97 insertions(+), 17 deletions(-) diff --git a/components/Modal/DisableModal.spec.js b/components/Modal/DisableModal.spec.js index e1db4a6d4..920122842 100644 --- a/components/Modal/DisableModal.spec.js +++ b/components/Modal/DisableModal.spec.js @@ -1,4 +1,4 @@ -import { mount, createLocalVue } from '@vue/test-utils' +import { shallowMount, mount, createLocalVue } from '@vue/test-utils' import DisableModal from './DisableModal.vue' import Vue from 'vue' import Styleguide from '@human-connection/styleguide' @@ -8,23 +8,76 @@ const localVue = createLocalVue() localVue.use(Styleguide) describe('DisableModal.vue', () => { - let Wrapper let store let mocks let propsData + let wrapper beforeEach(() => { propsData = {} mocks = { - $t: () => {}, + $filters: { + truncate: a => a + }, + $toast: { + success: () => {}, + error: () => {} + }, + $t: jest.fn(), $apollo: { - mutate: jest.fn().mockResolvedValue(null) + mutate: jest.fn().mockResolvedValue() } } }) + describe('shallowMount', () => { + const Wrapper = () => { + return shallowMount(DisableModal, { propsData, mocks, localVue }) + } + + describe('given a user', () => { + beforeEach(() => { + propsData = { + resource: { + type: 'user', + name: 'Bob Ross' + } + } + }) + + it('mentions user name', () => { + Wrapper() + const calls = mocks.$t.mock.calls + const expected = [['disable.user.message', { name: 'Bob Ross' }]] + expect(calls).toEqual(expect.arrayContaining(expected)) + }) + }) + + describe('given a contribution', () => { + beforeEach(() => { + propsData = { + resource: { + type: 'contribution', + name: 'This is some post content.' + } + } + }) + + it('mentions contribution title', () => { + Wrapper() + const calls = mocks.$t.mock.calls + const expected = [ + [ + 'disable.contribution.message', + { name: 'This is some post content.' } + ] + ] + expect(calls).toEqual(expect.arrayContaining(expected)) + }) + }) + }) + describe('mount', () => { - let wrapper const Wrapper = () => { return mount(DisableModal, { propsData, mocks, localVue }) } diff --git a/components/Modal/DisableModal.vue b/components/Modal/DisableModal.vue index 36692763e..ceafea7c3 100644 --- a/components/Modal/DisableModal.vue +++ b/components/Modal/DisableModal.vue @@ -1,18 +1,24 @@