-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(template): add test to vue3 template
- Loading branch information
1 parent
3ad506e
commit bcaf17a
Showing
10 changed files
with
467 additions
and
259 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
30 changes: 30 additions & 0 deletions
30
packages/cli/templates/vue3/src/components/FieldPluginExample/index.spec.ts
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,30 @@ | ||
import { render, screen } from '@testing-library/vue' | ||
import userEvent from '@testing-library/user-event' | ||
import { describe, test, expect } from 'vitest' | ||
import { setupFieldPlugin } from '@storyblok/field-plugin/test' | ||
import { nextTick } from 'vue' | ||
import FieldPlugin from './index.vue' | ||
|
||
describe('FieldPluginExample', async () => { | ||
test('should render the component', async () => { | ||
const { cleanUp } = setupFieldPlugin() | ||
render(FieldPlugin) | ||
await nextTick() | ||
const headline = screen.getByText('Field Value') | ||
expect(headline).toBeInTheDocument() | ||
cleanUp() | ||
}) | ||
|
||
test('should increase the counter', async () => { | ||
const { cleanUp } = setupFieldPlugin() | ||
const user = userEvent.setup() | ||
render(FieldPlugin) | ||
await nextTick() | ||
expect(screen.getByTestId('count').textContent).toEqual('0') | ||
await user.click(screen.getByText('Increment')) | ||
expect(screen.getByTestId('count').textContent).toEqual('1') | ||
await user.click(screen.getByText('Increment')) | ||
expect(screen.getByTestId('count').textContent).toEqual('2') | ||
cleanUp() | ||
}) | ||
}) |
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,8 @@ | ||
import { afterEach } from 'vitest' | ||
import { cleanup } from '@testing-library/vue' | ||
import '@testing-library/jest-dom/vitest' | ||
|
||
// runs a cleanup after each test case (e.g. clearing jsdom) | ||
afterEach(() => { | ||
cleanup() | ||
}) |
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 |
---|---|---|
|
@@ -8,6 +8,6 @@ | |
}, | ||
"dependencies": { | ||
"@storyblok/field-plugin": "workspace:*", | ||
"vitest": "0.34.6" | ||
"vitest": "1.0.1" | ||
} | ||
} |
Oops, something went wrong.