Skip to content

Commit

Permalink
Merge pull request #268 from cosmos/matt/233-common-tests
Browse files Browse the repository at this point in the history
Matt's share of the tests
  • Loading branch information
nylira authored Dec 27, 2017
2 parents c5a477d + 68e776a commit 7182fad
Show file tree
Hide file tree
Showing 14 changed files with 185 additions and 48 deletions.
40 changes: 0 additions & 40 deletions app/src/renderer/components/common/NiPageMenu.vue

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/renderer/components/common/NiSession.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default {
SessionAccountDelete
},
computed: {
...mapGetters(['config', 'config']),
...mapGetters(['config']),
active () { return this.config.modals.session.active }
},
beforeDestroy () {
Expand Down
18 changes: 17 additions & 1 deletion test/unit/specs/NISession.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ describe('NiSessionWelcome', () => {
'session-welcome': '<session-welcome />',
'session-sign-up': '<session-sign-up />',
'session-sign-in': '<session-sign-in />',
'session-hardware': '<session-hardware />'
'session-hardware': '<session-hardware />',
'session-restore': '<session-restore />',
'session-account-delete': '<session-account-delete />'
}
})
})
Expand Down Expand Up @@ -58,4 +60,18 @@ describe('NiSessionWelcome', () => {
wrapper.update()
expect(wrapper.contains('session-hardware')).toBe(true)
})

it('should show a account delete screen if selected', () => {
store.commit('setModalSession', true)
store.commit('setModalSessionState', 'delete')
wrapper.update()
expect(wrapper.contains('session-account-delete')).toBe(true)
})

// it('should show a restore screen if selected', () => {
// store.commit('setModalSession', true)
// store.commit('setModalSessionState', 'restore')
// wrapper.update()
// expect(wrapper.contains('session-restore')).toBe(true)
// })
})
4 changes: 2 additions & 2 deletions test/unit/specs/NISessionAccountDelete.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('NiSessionAccountDelete', () => {
expect(store.commit.mock.calls[0]).toEqual(['setModalSessionState', 'sign-in'])
})

it('should open the help model on click', () => {
it('should open the help modal on click', () => {
wrapper.findAll('.ni-session-header a').at(1).trigger('click')
expect(store.commit.mock.calls[0]).toEqual(['setModalHelp', true])
})
Expand Down Expand Up @@ -65,7 +65,7 @@ describe('NiSessionAccountDelete', () => {
})

it('should show a notification if deletion failed', async () => {
store.dispatch = jest.fn(() => Promise.reject('Planed rejection'))
store.dispatch = jest.fn(() => Promise.reject('Planned rejection'))
wrapper.setData({ fields: {
deletionPassword: '1234567890',
deletionWarning: true
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/NISessionHardware.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('NISessionHardware', () => {
expect(store.commit.mock.calls[0][1]).toBe('welcome')
})

it('should open the help model on click', () => {
it('should open the help modal on click', () => {
wrapper.findAll('.ni-session-header a').at(1).trigger('click')
expect(store.commit.mock.calls[0]).toEqual(['setModalHelp', true])
})
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/NISessionSignUp.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('NISessionSignUp', () => {
expect(store.commit.mock.calls[0][1]).toBe('welcome')
})

it('should open the help model on click', () => {
it('should open the help modal on click', () => {
wrapper.findAll('.ni-session-header a').at(1).trigger('click')
expect(store.commit.mock.calls[0]).toEqual(['setModalHelp', true])
})
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/NISessionWelcome.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('NISessionWelcome', () => {
})

describe('without accounts', () => {
it('should open the help model on click', () => {
it('should open the help modal on click', () => {
wrapper.findAll('.ni-session-header a').at(1).trigger('click')
expect(store.commit.mock.calls[0]).toEqual(['setModalHelp', true])
})
Expand Down
50 changes: 50 additions & 0 deletions test/unit/specs/NiPart.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { mount } from 'vue-test-utils'
import NiPart from 'common/NiPart'

describe('NiPart', () => {
let wrapper

beforeEach(() => {
wrapper = mount(NiPart, {
propsData: {
title: 'Test'
}
})
})

it('has the expected html structure', () => {
expect(wrapper.vm.$el).toMatchSnapshot()
})

it('only has header if a title is defined', () => {
wrapper = mount(NiPart, {
slots: {
default: '<custom-main />'
}
})
expect(wrapper.find('header').exists()).toBe(false)
expect(wrapper.find('custom-main').exists()).toBe(true)
})

it('gets title from prop if defined', () => {
wrapper = mount(NiPart, {
propsData: {
title: 'Test'
}
})
expect(wrapper.find('.ni-part-title').text()).toBe('Test')
})

it('should use slots', () => {
wrapper = mount(NiPart, {
slots: {
title: '<custom-title />',
default: '<custom-main />',
menu: '<custom-menu />'
}
})
expect(wrapper.find('custom-title').exists()).toBe(true)
expect(wrapper.find('custom-menu').exists()).toBe(true)
expect(wrapper.find('custom-main').exists()).toBe(true)
})
})
2 changes: 1 addition & 1 deletion test/unit/specs/NiSessionRestore.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('NiSessionRestore', () => {
expect(store.commit.mock.calls[0][1]).toBe('welcome')
})

it('should open the help model on click', () => {
it('should open the help modal on click', () => {
wrapper.findAll('.ni-session-header a').at(1).trigger('click')
expect(store.commit.mock.calls[0]).toEqual(['setModalHelp', true])
})
Expand Down
18 changes: 18 additions & 0 deletions test/unit/specs/NiTabBar.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { mount } from 'vue-test-utils'
import NiTabBar from 'common/NiTabBar'

describe('NiTabBar', () => {
let wrapper

beforeEach(() => {
wrapper = mount(NiTabBar, {
slots: {
default: '<main-slot />'
}
})
})

it('has the expected html structure', () => {
expect(wrapper.vm.$el).toMatchSnapshot()
})
})
40 changes: 40 additions & 0 deletions test/unit/specs/NiTag.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { mount } from 'vue-test-utils'
import NiTag from 'common/NiTag'

describe('NiTag', () => {
let wrapper

it('has the expected html structure', () => {
wrapper = mount(NiTag, {})
expect(wrapper.vm.$el).toMatchSnapshot()
})

it('has the expected value', () => {
wrapper = mount(NiTag, {
propsData: { value: 'Value' }
})
expect(wrapper.vm.$el.textContent).toBe('Value')
})

it('has the expected classes for default size', () => {
wrapper = mount(NiTag, {})
expect(wrapper.find('.ni-tag').exists()).toBe(true)
expect(wrapper.find('.ni-tag-df').exists()).toBe(true)
})

it('has the expected classes for small size', () => {
wrapper = mount(NiTag, {
propsData: { size: 'sm' }
})
expect(wrapper.find('.ni-tag').exists()).toBe(true)
expect(wrapper.find('.ni-tag-sm').exists()).toBe(true)
})

it('has the expected classes for large size', () => {
wrapper = mount(NiTag, {
propsData: { size: 'lg' }
})
expect(wrapper.find('.ni-tag').exists()).toBe(true)
expect(wrapper.find('.ni-tag-lg').exists()).toBe(true)
})
})
31 changes: 31 additions & 0 deletions test/unit/specs/__snapshots__/NiPart.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`NiPart has the expected html structure 1`] = `
<section
class="ni-part"
>
<div
class="ni-part-container"
>
<header
class="ni-part-header"
>
<div
class="ni-part-header-container"
>
<div
class="ni-part-title h5"
>
Test
</div>
<menu
class="ni-part-menu"
/>
</div>
</header>
<main
class="ni-part-main"
/>
</div>
</section>
`;
13 changes: 13 additions & 0 deletions test/unit/specs/__snapshots__/NiTabBar.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`NiTabBar has the expected html structure 1`] = `
<div
class="ni-tab-bar"
>
<div
class="ni-tab-bar-container"
>
<main-slot />
</div>
</div>
`;
9 changes: 9 additions & 0 deletions test/unit/specs/__snapshots__/NiTag.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`NiTag has the expected html structure 1`] = `
<div
class="ni-tag ni-tag ni-tag-df"
>
</div>
`;

0 comments on commit 7182fad

Please sign in to comment.