Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions tests/e2e/specs/LicenseUseCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {

'Check if the main div tag with the class license-use-card is present': function(browser) {
browser
.init()
.assert.elementPresent('.control-label > span')
.click('.control-label > span')
.assert.elementPresent('.pagination-next')
.click('.pagination-next')
.assert.elementPresent('.select')
.click('.select')
.click('option[value="CC BY 4.0"]')
.assert.elementPresent('.pagination-next')
.click('.pagination-next')
.assert.elementPresent('.license-use-card')
},
'Check if the elements are present inside the main div': function(browser) {
browser
.assert.elementPresent('.license-use-card h4')
.assert.elementPresent('nav[class="tabs"]')
.assert.elementPresent('.tab-content')
.assert.elementPresent('.license-use-instructions')
.expect.element('.license-use-instructions').text.to.equal('Choose what kind of work you are licensing to get appropriate license code.')
},
'Check if the tab items are present in the DOM': function(browser) {
browser
.assert.elementPresent('.tab-item')
.assert.elementPresent('.tab-content > div:nth-child(1)')
.assert.elementPresent('.tab-content > div:nth-child(2)')
}
}
57 changes: 57 additions & 0 deletions tests/unit/specs/components/LicenseUseCard.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { shallowMount, createLocalVue, config } from '@vue/test-utils'
import LicenseUseCard from '@/components/LicenseUseCard.vue'
import VueI18n from 'vue-i18n'
import Buefy from 'buefy'

describe('LicenseUseCard.vue', () => {
let wrapper

// Always creates a shallow instance of component
beforeEach(() => {
const localVue = createLocalVue()
localVue.use(VueI18n)
localVue.use(Buefy)
const messages = require('@/locales/en.json')
const i18n = new VueI18n({
locale: 'en',
fallbackLocale: 'en',
messages: messages,
silentTranslationWarn: true
})

config.mocks.i18n = i18n

config.mocks.$t = (key) => {
return i18n.messages[key]
}
wrapper = shallowMount(LicenseUseCard, {
localVue,
i18n
})
})

it('Check if the LicenseUseCard.vue component renders without any errors', () => {
expect(wrapper.isVueInstance()).toBeTruthy()
})

// Test for DOM elements which must be present
it('Check if the main div tag with the class license-use-card is present', () => {
expect(wrapper.contains('.license-use-card')).toBe(true)
})
it('Check if the main header is present in the DOM', () => {
expect(wrapper.contains('.license-use-card h4')).toBe(true)
})
it('Check if the common instructions are present in the DOM', () => {
expect(wrapper.contains('.license-use-instructions')).toBe(true)
})
it('Check if the tab and the tab items are present in the DOM', () => {
expect(wrapper.contains('b-tabs-stub')).toBe(true)
expect(wrapper.contains('b-tab-item-stub')).toBe(true)
expect(wrapper.findAll('b-tab-item-stub').length).toBe(2)
})

// Snapshot tests
it('LicenseUseCard.vue component has the expected UI', () => {
expect(wrapper).toMatchSnapshot()
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`LicenseUseCard.vue LicenseUseCard.vue component has the expected UI 1`] = `
<div class="license-use-card">
<h4 class="vocab h4b hb">

</h4>
<p class="license-use-instructions">

</p>
<b-tabs-stub animated="true">
<b-tab-item-stub visible="true">

<licensecopy-stub isweb="true"></licensecopy-stub>
</b-tab-item-stub>
<b-tab-item-stub visible="true">

<licensecopy-stub></licensecopy-stub>
</b-tab-item-stub>
</b-tabs-stub>
</div>
`;