Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
Cr0zy07 committed Nov 29, 2023
1 parent b0d70db commit ddc2bf3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`okuLabel > should render OkuLabel correctly 1`] = `"<oku-label-stub aschild=\\"false\\"></oku-label-stub>"`;
exports[`okuLabel > should render OkuLabel correctly 2`] = `"<primitivelabel-stub aschild=\\"false\\"></primitivelabel-stub>"`;
exports[`okuLabel Stories > styled > should render correctly 1`] = `"<oku-label-stub aschild=\\"false\\" class=\\"label\\"></oku-label-stub>"`;
exports[`okuLabel Stories > withControl > should render correctly 1`] = `
Expand Down
25 changes: 14 additions & 11 deletions packages/components/label/tests/label.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { enableAutoUnmount, shallowMount } from '@vue/test-utils'
import { enableAutoUnmount, mount, shallowMount } from '@vue/test-utils'

Check failure on line 1 in packages/components/label/tests/label.test.ts

View workflow job for this annotation

GitHub Actions / build-test (ubuntu-latest, 20)

'mount' is defined but never used
import type { VueWrapper } from '@vue/test-utils'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { axe } from 'vitest-axe'
Expand All @@ -10,19 +10,23 @@ import WithControl from '../src/stories/WithControl.vue'

enableAutoUnmount(afterEach)

describe.skip('okuLabel', () => {
describe('okuLabel', () => {
let wrapper: VueWrapper

const onMousedown = vi.fn()

beforeEach(() => {
wrapper = shallowMount({
components: {
OkuLabel,
},
setup() {
return { }
return {
onMousedown,
}
},
template: `
<OkuLabel>
<OkuLabel @mousedown="onMousedown">
Label
</OkuLabel>
`,
Expand All @@ -44,17 +48,16 @@ describe.skip('okuLabel', () => {
expect(await axe(wrapper.element)).toHaveNoViolations()
})

// TODO: mock preventDefault()
it('should prevent default on double click', async () => {
const event = {
preventDefault: vi.fn(),
detail: 2,
}

await wrapper.trigger('mousedown', event)
await wrapper.trigger('mousedown')
await wrapper.trigger('mousedown')

expect(wrapper.emitted('mousedown')).toBeTruthy()
})

expect(event.preventDefault).toHaveBeenCalled()
it('should call `onMousedown` event', () => {
expect(onMousedown).toHaveBeenCalled()
})
})

Expand Down

0 comments on commit ddc2bf3

Please sign in to comment.