diff --git a/test/e2e/specs/components/SelectedLicense.js b/test/e2e/specs/components/SelectedLicense.js new file mode 100644 index 000000000..e2b7defdc --- /dev/null +++ b/test/e2e/specs/components/SelectedLicense.js @@ -0,0 +1,57 @@ +module.exports = { + + 'The title of the Selected License section' : function(browser) { + browser + .url(browser.globals.devServerURL) + .waitForElementVisible('#app', 1000) + .assert.elementPresent('.title') + .assert.containsText('h2', 'Selected License') + }, + + 'Default license "CC BY 4.0" and full license name display' : function(browser) { + browser + .assert.elementPresent('.selected-license-names') + .assert.containsText('.selected-license-name', 'CC BY 4.0') + .assert.containsText('.help', 'Atribution 4.0 International') + }, + + 'Default license information and description' : function(browser) { + browser + .assert.elementPresent('#chooser-selected-share_adapt') + .assert.containsText('#chooser-selected-share_adapt p', 'CC BY attribution means you allow people to') + .assert.containsText('#generated-license-share', ' the material in any medium or format') + .assert.containsText('#generated-license-adapt', ' it for any purpose, even commercially') + .assert.containsText('#chooser-selected-description', 'As the most accommodating of licenses offered, the CC BY license allows others to distribute, remix, tweak, and build upon your work, even commercially, as long as they credit you for the original creation.') + .end() + }, + + 'Icon is clicked to select a license and information is changed accordingly': function(browser) { + browser + .url(browser.globals.devServerURL) + .waitForElementVisible('#app', 1000) + .click('.nd') + .pause(1000) + .assert.containsText('.selected-license-name', 'CC BY-ND 4.0') + .assert.containsText('#chooser-selected-description', 'The CC BY-ND license begins to become less accommodating. BY-ND stipulates that people are free to distribute your work, even commercially, and must credit you with the original creation, but they are not allowed to remix, tweak, or build upon your work.') + .end() + + }, + + 'Description changes when CC BY-SA 4.0 license is choosen' : function(browser) { + browser + .url(browser.globals.devServerURL) + .waitForElementVisible('#app', 1000) + .click('.sa') + .assert.containsText('.selected-license-name', 'CC BY-SA 4.0') + .assert.containsText('#chooser-selected-description', 'The CC BY-SA license is realtively accommodating. Similar to the CC BY license, BY-SA allows others to distribute') + }, + + 'Click full license name directs url to https://creativecommons.org/licenses/by-sa/4.0/?ref=ccchooser' : function(browser) { + browser + .url(browser.globals.devServerURL) + .waitForElementVisible('#app', 1000) + .click('.help') + .assert.urlEquals('https://creativecommons.org/licenses/by-sa/4.0/?ref=ccchooser') + .end() + } +} \ No newline at end of file diff --git a/test/unit/specs/components/SelectedLicense.spec.js b/test/unit/specs/components/SelectedLicense.spec.js new file mode 100644 index 000000000..b85f137ce --- /dev/null +++ b/test/unit/specs/components/SelectedLicense.spec.js @@ -0,0 +1,84 @@ +import { shallowMount, createLocalVue } from '@vue/test-utils' +import licenseUrl from '@/utils/licenseUrl' +import SelectedLicense from '@/components/SelectedLicense' +import LicenseDescription from '@/components/LicenseDescription' + +describe('SelectedLicense.vue', () => { + + it('checks prop value of shortLicenseName is assigned correctly', () => { + const wrapper = shallowMount(SelectedLicense, { + propsData: { + shortLicenseName: 'CC BY 4.0' + } + }) + const ncWrapper = shallowMount(SelectedLicense, { + propsData: { + shortLicenseName: 'CC BY-NC 4.0' + } + }) + expect(wrapper.props().shortLicenseName).toBe('CC BY 4.0') + expect(ncWrapper.props().shortLicenseName).toBe('CC BY-NC 4.0') + }) + + it('checks fullLicenseName prop value is assigned correctly', () => { + const wrapper = shallowMount(SelectedLicense, { + propsData: { + shortLicenseName: 'CC BY 4.0', + fullLicenseName: 'Atribution 4.0 International' + } + }) + const ncWrapper = shallowMount(SelectedLicense, { + propsData: { + shortLicenseName: 'CC BY-NC 4.0', + fullLicenseName: 'Atribution-NonCommercial 4.0 International' + } + }) + expect(wrapper.props().fullLicenseName).toBe('Atribution 4.0 International') + expect(ncWrapper.props().fullLicenseName).toBe('Atribution-NonCommercial 4.0 International') + }) + + it ('correctly returns object for iconsList function', () => { + const wrapper = shallowMount(SelectedLicense, { + propsData: { + shortLicenseName: 'CC BY 4.0' + } + }) + const iconsListObj = wrapper.vm.iconsList + expect(typeof iconsListObj).toBe('object') + }) + + it('checks last index in array from iconsList function is correct', () => { + const wrapper = shallowMount(SelectedLicense, { + propsData: { + shortLicenseName: 'CC BY 4.0' + } + }) + const ncWrapper = shallowMount(SelectedLicense, { + propsData: { + shortLicenseName: 'CC BY-NC 4.0', + fullLicenseName: 'Atribution-NonCommercial 4.0 International' + } + }) + const lastIndex = wrapper.vm.iconsList + const NcLastIndex = ncWrapper.vm.iconsList + expect(lastIndex[lastIndex.length-1]).toBe('by') + expect(NcLastIndex[NcLastIndex.length-1]).toBe('nc') + }) + + it('sets link for href for license names', () => { + const wrapper = shallowMount(SelectedLicense, { + propsData: { + shortLicenseName: 'CC BY 4.0' + } + }) + const ncWrapper = shallowMount(SelectedLicense, { + propsData: { + shortLicenseName: 'CC BY-NC 4.0' + } + }) + expect(licenseUrl(wrapper.props().shortLicenseName)).toBe('https://creativecommons.org/licenses/by/4.0/?ref=ccchooser') + expect(licenseUrl(ncWrapper.props().shortLicenseName)).toBe('https://creativecommons.org/licenses/by-nc/4.0/?ref=ccchooser') + }) + + +}) \ No newline at end of file