Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests #36

Merged
merged 4 commits into from
Feb 25, 2025
Merged
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
1 change: 1 addition & 0 deletions src/components/ExternalLink.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<a
v-text="name"
data-test="link"
href="#"
:title="url"
@click.prevent="open('https://' + url)"
Expand Down
15 changes: 11 additions & 4 deletions tests/unit/components/ExternalLink.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import testHelpers from '@@/unit/testHelpers.js';
import ExternalLink from '@/components/ExternalLink.vue';

describe('ExternalLink.vue', () => {
// Props
const name = 'Test';
const url = 'example.com';

// Data
const fullUrl = 'https://' + url;

beforeEach(() => {
Expand All @@ -26,13 +29,15 @@ describe('ExternalLink.vue', () => {
const wrapper = await setupWrapper();

expect(wrapper)
.toMatchSnapshot();
.toMatchInlineSnapshot(`
<a href="#" title="example.com">Test</a>
`);
});

test('Click event', async () => {
const wrapper = await setupWrapper();

await wrapper.find('a').trigger('click');
await wrapper.find('[data-test="link"]').trigger('click');

expect(window.nw.Shell.openExternal)
.toHaveBeenCalledWith(fullUrl);
Expand All @@ -48,13 +53,15 @@ describe('ExternalLink.vue', () => {
const wrapper = await setupWrapper();

expect(wrapper)
.toMatchSnapshot();
.toMatchInlineSnapshot(`
<a href="#" title="example.com">Test</a>
`);
});

test('Click event', async () => {
const wrapper = await setupWrapper();

await wrapper.find('a').trigger('click');
await wrapper.find('[data-test="link"]').trigger('click');

expect(window.open)
.toHaveBeenCalledWith(fullUrl, '_blank');
Expand Down
5 changes: 0 additions & 5 deletions tests/unit/components/__snapshots__/ExternalLink.test.js.snap

This file was deleted.