-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: bump^ minor version "wait-on" * feat: adds VAction tests and linting fix + clean up git history
- Loading branch information
Showing
4 changed files
with
109 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { render } from '@testing-library/vue'; | ||
import { RouterLinkStub } from '@vue/test-utils'; | ||
import VActionStub from '../stubs/VActionStub.vue'; | ||
|
||
describe('VAction Unit Test', () => { | ||
describe('Default Functionality', () => { | ||
it('Returns a <RouterLink/> tag', () => { | ||
const { getByTestId } = render(VActionStub, { | ||
stubs: { | ||
RouterLink: RouterLinkStub | ||
}, | ||
}); | ||
|
||
const testLink = getByTestId('internal'); | ||
expect(testLink).toHaveAttribute( | ||
'to', | ||
expect.stringContaining('/internal-link') | ||
); | ||
}); | ||
it('Returns an anchor tag with :href', () => { | ||
const { getByTestId } = render(VActionStub); | ||
const testLink = getByTestId('external-href'); | ||
expect(testLink).toHaveAttribute( | ||
'href', | ||
expect.stringContaining('http://example.com/') | ||
); | ||
}); | ||
it('Fails to return an anchor tag with :attrs', () => { | ||
const { getByTestId } = render(VActionStub); | ||
const testLink = getByTestId('external-attrs'); | ||
expect(testLink).not.toHaveAttribute('href'); | ||
}); | ||
it('Fails to return an anchor tag with :data', () => { | ||
const { getByTestId } = render(VActionStub); | ||
const testLink = getByTestId('external-data'); | ||
expect(testLink).not.toHaveAttribute('href'); | ||
}); | ||
it('Returns a <button />', () => { | ||
const { getByTestId } = render(VActionStub); | ||
const testLink = getByTestId('button'); | ||
expect(testLink).toHaveTextContent('Button'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<template> | ||
<div> | ||
<!-- ROUTER LINK --> | ||
<v-action data-testid="internal" to="/internal-link"> | ||
Internal Link | ||
</v-action> | ||
<!-- ANCHOR TAG --> | ||
<!-- TEST WONT PASS --> | ||
<v-action data-testid="external-data" :data="data"> | ||
External Link | ||
</v-action> | ||
<!-- TEST WONT PASS --> | ||
<v-action data-testid="external-attrs" :attrs="attrs"> | ||
External Link | ||
</v-action> | ||
<!-- TEST WILL PASS --> | ||
<v-action data-testid="external-href" :href="attrs.href"> | ||
External Link | ||
</v-action> | ||
<!-- BUTTON --> | ||
<v-action data-testid="button"> | ||
Button | ||
</v-action> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
// TURNS OFF ERROR IN CONSOLE for UNIT TEST | ||
import { RouterLinkStub } from '@vue/test-utils'; | ||
const RouterLink = RouterLinkStub; | ||
import VAction from '../../../../src/components/VAction/VAction.vue'; | ||
export default { | ||
name: 'VActionStub', | ||
components: { | ||
VAction, | ||
// eslint-disable-next-line vue/no-unused-components | ||
RouterLink | ||
}, | ||
data() { | ||
return { | ||
attrs: { | ||
href: 'http://example.com/', | ||
}, | ||
}; | ||
}, | ||
}; | ||
</script> |