@@ -2,6 +2,7 @@ import { mount, createLocalVue } from '@vue/test-utils'
22import SelectedLicenseCode from '@/components/SelectedLicenseCode'
33import Buefy from 'buefy'
44import sinon from 'sinon'
5+ import LicenseUtilities from '@/utils/license-utilities'
56
67const value = {
78 shortName : 'CC BY 4.0' ,
@@ -28,11 +29,12 @@ function _mockDomMethodsForClipboardJS(value) {
2829describe ( 'SelectedLicenseCode.vue' , ( ) => {
2930 let wrapper
3031 let spy
31- let clipboard
3232
3333 beforeEach ( ( ) => {
3434 const localVue = createLocalVue ( )
3535 localVue . use ( Buefy )
36+ localVue . use ( LicenseUtilities )
37+
3638 _mockDomMethodsForClipboardJS ( )
3739 spy = sinon . stub ( )
3840 wrapper = mount ( SelectedLicenseCode , {
@@ -91,15 +93,17 @@ describe('SelectedLicenseCode.vue', () => {
9193 // Test copying
9294 it ( 'Copies text from active tab' , ( ) => {
9395 const copyLink = wrapper . findAll ( 'li' ) . at ( 2 ) . find ( 'a' ) . find ( 'span' ) . find ( 'a' )
96+
9497 expect ( wrapper . vm . currentTab ) . toEqual ( 0 )
95- expect ( wrapper . vm . clipboardTarget ) . toEqual ( '#attribution-richtext' )
96- wrapper . findAll ( 'li' ) . at ( 1 ) . find ( 'a' ) . trigger ( 'click ')
97- expect ( wrapper . vm . clipboardTarget ) . toEqual ( '#attribution-html ')
98+ expect ( wrapper . vm . clipboardTarget ( ) ) . toEqual ( '#attribution-richtext' )
99+ const htmlTab = wrapper . findAll ( 'li' ) . at ( 1 ) . find ( 'a' )
100+ htmlTab . trigger ( 'click ')
98101 copyLink . trigger ( 'click' )
99- expect ( wrapper . vm . clipboardTarget ) . toEqual ( '#attribution-html' )
102+ expect ( wrapper . vm . clipboardTarget ( ) ) . toEqual ( '#attribution-html' )
103+ expect ( wrapper . vm . currentSelection ) . toEqual ( 'html' )
104+
100105 const emittedEvents = wrapper . emitted ( )
101106 expect ( emittedEvents ) . toHaveProperty ( 'copyFailed' )
102107 expect ( emittedEvents . copyFailed . length ) . toBe ( 1 )
103108 } )
104-
105109} )
0 commit comments