Skip to content

Commit

Permalink
Fixed the unit test in GeneBox testing the copy to clipboard function…
Browse files Browse the repository at this point in the history
…ality
  • Loading branch information
JmScherer committed Nov 10, 2023
1 parent 80d195e commit c6b8dba
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions frontend/test/components/AnalysisView/GeneBox.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect, describe, it, beforeAll, afterAll, vi} from 'vitest';
import {expect, describe, it, beforeAll, afterAll} from 'vitest';
import {config, shallowMount} from '@vue/test-utils';

import GeneBox from '@/components/AnalysisView/GeneBox.vue';
Expand Down Expand Up @@ -105,17 +105,25 @@ describe('GeneBox.vue', () => {
expect(wrapper.text()).to.contains('PS2, PS3, PM2, PP3, PP5');
});

/*
this test will need to be modified when the copy functionality is added
copy method needs to be changed to navigator.clipboard.writeText(textToCopy);
*/
it('should log text to console when copy button is clicked', async () => {
let clipboardContents = '';

window.__defineGetter__('navigator', function() {
return {
clipboard: {
writeText: (text) => {
clipboardContents = text;
},
},
};
});

const wrapper = getMountedComponent();

const copyButton = wrapper.find('[data-test=copy-button]');
vi.spyOn(console, 'log');
await copyButton.trigger('click');
expect(console.log).toHaveBeenCalled();

expect(clipboardContents).to.equal('NM_170707.3:c.745C>T');
});

it('should route to annotations for a gene', async () => {
Expand Down

0 comments on commit c6b8dba

Please sign in to comment.