-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #249 from cosmos/peng/230-unit-tests-for-common
Peng/230 unit tests for common
- Loading branch information
Showing
34 changed files
with
599 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { mount } from 'vue-test-utils' | ||
import htmlBeautify from 'html-beautify' | ||
import NiDataLoading from 'common/NiDataLoading' | ||
|
||
describe('NiDataLoading', () => { | ||
let wrapper | ||
beforeEach(() => { | ||
wrapper = mount(NiDataLoading) | ||
}) | ||
|
||
it('has the expected html structure', () => { | ||
expect(htmlBeautify(wrapper.html())).toMatchSnapshot() | ||
}) | ||
|
||
it('has an icon', () => { | ||
expect(wrapper.find('.ni-data-msg__icon i.material-icons').text().trim()) | ||
.toBe('rotate_right') | ||
}) | ||
|
||
it('has a spinning icon', () => { | ||
expect(wrapper.find('.ni-data-msg__icon').contains('i.material-icons.fa-spin')) | ||
.toBe(true) | ||
}) | ||
|
||
it('has a title', () => { | ||
expect(wrapper.find('.ni-data-msg__title div').text().trim()) | ||
.toBe('Data is loading…') | ||
}) | ||
|
||
it('has a subtitle', () => { | ||
expect(wrapper.find('.ni-data-msg__subtitle div').text().trim()) | ||
.toBe('Please wait a moment.') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { mount } from 'vue-test-utils' | ||
import htmlBeautify from 'html-beautify' | ||
import NiDataMsg from 'common/NiDataMsg' | ||
|
||
describe('NiDataMsg', () => { | ||
let wrapper | ||
|
||
let propsData = { | ||
title: 'sOmEtHiNg Is HaPpEnIng!!!', | ||
subtitle: 'Oh my! What could it be?', | ||
icon: 'help', | ||
spin: false | ||
} | ||
|
||
beforeEach(() => { | ||
wrapper = mount(NiDataMsg, { propsData }) | ||
}) | ||
|
||
it('has a title from props', () => { | ||
expect(wrapper.vm.title).toBe('sOmEtHiNg Is HaPpEnIng!!!') | ||
}) | ||
|
||
it('has the expected html structure', () => { | ||
expect(htmlBeautify(wrapper.html())).toMatchSnapshot() | ||
}) | ||
|
||
it('has an icon', () => { | ||
expect(wrapper.find('.ni-data-msg__icon i.material-icons').text()) | ||
.toBe('help') | ||
}) | ||
|
||
it('doesn\'t have a spinning icon', () => { | ||
expect(wrapper.find('.ni-data-msg__icon').contains('i.material-icons.fa-spin')) | ||
.toBe(false) | ||
}) | ||
|
||
it('has a subtitle', () => { | ||
expect(wrapper.find('.ni-data-msg__subtitle').text()) | ||
.toBe('Oh my! What could it be?') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { mount } from 'vue-test-utils' | ||
import htmlBeautify from 'html-beautify' | ||
import NiFieldAddon from 'common/NiFieldAddon' | ||
|
||
describe('NiFieldAddon', () => { | ||
let wrapper | ||
|
||
beforeEach(() => { | ||
wrapper = mount(NiFieldAddon, { | ||
slots: { | ||
default: '<div class="fake-addon">ATOM</div>' | ||
} | ||
}) | ||
}) | ||
|
||
it('has the expected html structure', () => { | ||
expect(htmlBeautify(wrapper.html())).toMatchSnapshot() | ||
}) | ||
|
||
it('has a slot with content', () => { | ||
expect(wrapper.findAll('.fake-addon').length).toBe(1) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { mount } from 'vue-test-utils' | ||
import htmlBeautify from 'html-beautify' | ||
import NiFieldGroup from 'common/NiFieldGroup' | ||
|
||
describe('NiFieldGroup', () => { | ||
let wrapper | ||
|
||
beforeEach(() => { | ||
wrapper = mount(NiFieldGroup, { | ||
slots: { | ||
default: '<input class="fake-field" placeholder="Fake">' | ||
} | ||
}) | ||
}) | ||
|
||
it('has the expected html structure', () => { | ||
expect(htmlBeautify(wrapper.html())).toMatchSnapshot() | ||
}) | ||
|
||
it('has a slot with a field', () => { | ||
expect(wrapper.findAll('.fake-field').length).toBe(1) | ||
}) | ||
}) |
Oops, something went wrong.