-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
106 additions
and
20 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
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,29 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`Icon.ts > It should render standalone 1`] = ` | ||
"<svg class="carousel__icon" viewBox="0 0 24 24" role="img" aria-label="Arrow pointing upwards"> | ||
<title>Arrow pointing upwards</title> | ||
<path d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"></path> | ||
</svg>" | ||
`; | ||
|
||
exports[`Icon.ts > It should render standalone 2`] = ` | ||
"<svg class="carousel__icon" viewBox="0 0 24 24" role="img" aria-label="Arrow pointing downwards"> | ||
<title>Arrow pointing downwards</title> | ||
<path d="M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"></path> | ||
</svg>" | ||
`; | ||
|
||
exports[`Icon.ts > It should render standalone 3`] = ` | ||
"<svg class="carousel__icon" viewBox="0 0 24 24" role="img" aria-label="Arrow pointing to the right"> | ||
<title>Arrow pointing to the right</title> | ||
<path d="M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z"></path> | ||
</svg>" | ||
`; | ||
|
||
exports[`Icon.ts > It should render standalone 4`] = ` | ||
"<svg class="carousel__icon" viewBox="0 0 24 24" role="img" aria-label="Arrow pointing to the left"> | ||
<title>Arrow pointing to the left</title> | ||
<path d="M15.41 16.59L10.83 12l4.58-4.59L14 6l-6 6 6 6 1.41-1.41z"></path> | ||
</svg>" | ||
`; |
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,38 @@ | ||
import { expect, it, describe, beforeAll, afterEach } from 'vitest' | ||
|
||
import { mount } from '@vue/test-utils' | ||
|
||
import { Icon } from '@/index' | ||
import { IconProps } from '@/components/Icon' | ||
import { IconName } from '../../src/partials/icons' | ||
|
||
describe('Icon.ts', () => { | ||
const consoleMock = vi.spyOn(console, 'warn').mockImplementation(() => undefined); | ||
|
||
afterEach(() => { | ||
consoleMock.mockReset(); | ||
}); | ||
|
||
it('It should error if no iconName', () => { | ||
const wrapper = mount(Icon, { props: {} }) | ||
expect(wrapper.html()).toBe("") | ||
expect(consoleMock).toHaveBeenCalledOnce(); | ||
expect(consoleMock.mock.calls[0][0]).toBe('[Vue warn]: Missing required prop: "name"'); | ||
}) | ||
|
||
it('It should error if iconName is invalid', () => { | ||
const wrapper = mount(Icon, { props: { name: 'foo' } }) | ||
expect(wrapper.html()).toBe("") | ||
console.log(consoleMock.mock.calls) | ||
expect(consoleMock).toHaveBeenCalledOnce(); | ||
expect(consoleMock.mock.calls[0][0]).toBe('[Vue warn]: Invalid prop: custom validator check failed for prop "name".'); | ||
}) | ||
|
||
it('It should render standalone', () => { | ||
Object.values(IconName).forEach((name) => { | ||
const wrapper = mount(Icon, { props: { name: name } as IconProps }) | ||
expect(consoleMock).not.toHaveBeenCalled() | ||
expect(wrapper.html()).toMatchSnapshot() | ||
}) | ||
}) | ||
}) |