Skip to content

Commit f1a9564

Browse files
committed
Update Help Section tests
Signed-off-by: Olga Bulat <obulat@gmail.com>
1 parent 714e7b0 commit f1a9564

File tree

3 files changed

+111
-189
lines changed

3 files changed

+111
-189
lines changed

tests/unit/specs/components/HelpSection.spec.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { shallowMount, createLocalVue } from '@vue/test-utils'
1+
import {shallowMount, createLocalVue, config} from '@vue/test-utils'
22
import HelpSection from '@/components/HelpSection'
33
import Buefy from 'buefy'
44
import LicenseUtilities from '@/utils/license-utilities'
5+
import Vue from 'vue'
6+
import VueI18n from 'vue-i18n'
57

68
describe('HelpSection.vue', () => {
79
let wrapper
@@ -11,7 +13,17 @@ describe('HelpSection.vue', () => {
1113
const localVue = createLocalVue()
1214
localVue.use(Buefy)
1315
localVue.use(LicenseUtilities)
14-
16+
Vue.use(VueI18n)
17+
const messages = require('@/locales/en.json')
18+
const i18n = new VueI18n({
19+
locale: 'en',
20+
fallbackLocale: 'en',
21+
messages: messages
22+
})
23+
config.mocks.i18n = i18n
24+
config.mocks.$t = (key) => {
25+
return i18n.messages[key]
26+
}
1527
wrapper = shallowMount(HelpSection, {
1628
localVue
1729
})
@@ -48,7 +60,7 @@ describe('HelpSection.vue', () => {
4860
})
4961

5062
it('expects isModal3Active to be true after clicking it', () => {
51-
const button = wrapper.find('#public_domain_btn')
63+
const button = wrapper.find('#icons_meaning_btn')
5264
button.trigger('click')
5365
expect(wrapper.vm.isModal3Active).toEqual(true)
5466
})

tests/unit/specs/components/LicenseDropdown.spec.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import {config, createLocalVue, mount} from '@vue/test-utils'
2-
import SelectedLicenseDropdown from '@/components/SelectedLicenseDropdown'
3-
import Buefy from 'buefy'
4-
import LicenseUtilities from '@/utils/license-utilities'
51
import Vue from 'vue'
62
import VueI18n from 'vue-i18n'
3+
import Buefy from 'buefy'
4+
import {config, createLocalVue, mount} from '@vue/test-utils'
5+
import LicenseUtilities from '@/utils/license-utilities'
6+
import SelectedLicenseDropdown from '@/components/SelectedLicenseDropdown'
77

88
const value = {
99
shortName: 'CC BY 4.0',
@@ -29,9 +29,7 @@ describe('LicenseDropdown.vue', () => {
2929
fallbackLocale: 'en',
3030
messages: messages
3131
})
32-
3332
config.mocks.i18n = i18n
34-
3533
config.mocks.$t = (key) => {
3634
return i18n.messages[key]
3735
}
@@ -43,14 +41,12 @@ describe('LicenseDropdown.vue', () => {
4341
})
4442
})
4543
describe('correctly displays initial information and options when mounted', () => {
46-
4744
it('initializes with base license names', () => {
4845
expect(wrapper.vm.$props.value.shortName).toEqual('CC BY 4.0')
4946
expect(wrapper.vm.$props.value.fullName).toEqual('Attribution 4.0 International')
5047
expect(wrapper.html()).toContain('CC BY 4.0')
5148
expect(wrapper.findAll('option')).toHaveLength(7)
5249
})
53-
5450
it('calculate fullLicenseName correctly', () => {
5551
wrapper.vm.value.shortName = 'CC BY-ND 4.0'
5652
expect(wrapper.vm.fullLicenseName('CC BY-ND 4.0')).toEqual('Attribution-NoDerivatives 4.0 International')

0 commit comments

Comments
 (0)