Skip to content

Commit fec4b46

Browse files
nandi95lmiller1990
authored andcommitted
Fixed test typings
1 parent 7c8caf7 commit fec4b46

17 files changed

+43
-33
lines changed

src/createDomEvent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// @ts-expect-error No DefinitelyTyped package exists
1+
// @ts-ignore No DefinitelyTyped package exists
22
import eventTypes from 'dom-event-types'
33

44
interface TriggerOptions {

src/vueWrapper.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,20 @@ export class VueWrapper<T extends ComponentPublicInstance> {
6161
classes(): string[]
6262
classes(className: string): boolean
6363
classes(className?: string): string[] | boolean {
64-
return new DOMWrapper(this.element).classes(className)
64+
return new DOMWrapper(this.element).classes(className!)
6565
}
6666

6767
attributes(): { [key: string]: string }
6868
attributes(key: string): string
6969
attributes(key?: string): { [key: string]: string } | string {
70-
return new DOMWrapper(this.element).attributes(key)
70+
return new DOMWrapper(this.element).attributes(key!)
7171
}
7272

7373
exists() {
7474
return true
7575
}
7676

77-
emitted<T = unknown>(): undefined | Record<string, T[]>
77+
emitted<T = unknown>(): Record<string, T[]>
7878
emitted<T = unknown>(eventName?: string): undefined | T[]
7979
emitted<T = unknown>(
8080
eventName?: string

tests/config.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { h, inject } from 'vue'
1+
import { ComponentPublicInstance, h, inject } from 'vue'
22
import { config, mount } from '../src'
33
import Hello from './components/Hello.vue'
44

@@ -114,7 +114,7 @@ describe('config', () => {
114114
describe('provide', () => {
115115
const Comp = {
116116
setup() {
117-
const theme = inject('theme')
117+
const theme = inject<string>('theme')
118118
return () => h('div', theme)
119119
}
120120
}
@@ -163,14 +163,14 @@ describe('config', () => {
163163
expect(createdHook).toHaveBeenCalledTimes(2)
164164
})
165165

166-
it('concats with locally defined mixins', () => {
166+
it('concat with locally defined mixins', () => {
167167
config.global.mixins = [mixin]
168168
const localHook = jest.fn()
169169
const localMixin = {
170170
created() {
171-
localHook(this.$options.name)
171+
localHook(this.$options!.name)
172172
}
173-
}
173+
} as Partial<ComponentPublicInstance>
174174

175175
mount(Component, {
176176
global: {

tests/emit.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ describe('emitted', () => {
9393
name: 'Parent',
9494
setup(props, { emit }) {
9595
return () =>
96-
h(Child, { onHello: (...events) => emit('parent', ...events) })
96+
h(Child, { onHello: (...events: any[]) => emit('parent', ...events) })
9797
}
9898
})
9999
const wrapper = mount(Parent)
@@ -130,10 +130,10 @@ describe('emitted', () => {
130130
expect(wrapper.emitted('hello')).toEqual(undefined)
131131

132132
wrapper.find('button').trigger('click')
133-
expect(wrapper.emitted('hello')[0]).toEqual(['foo', 'bar'])
133+
expect((wrapper.emitted('hello') as unknown[])[0]).toEqual(['foo', 'bar'])
134134

135135
wrapper.find('button').trigger('click')
136-
expect(wrapper.emitted('hello')[1]).toEqual(['foo', 'bar'])
136+
expect((wrapper.emitted('hello') as unknown[])[1]).toEqual(['foo', 'bar'])
137137

138138
expect(wrapper.emitted('hello')).toHaveLength(2)
139139
})
@@ -157,7 +157,7 @@ describe('emitted', () => {
157157

158158
wrapper.find('h1').trigger('click')
159159
expect(wrapper.emitted('hello')).toHaveLength(1)
160-
expect(wrapper.emitted('hello')[0]).toEqual(['foo', 'bar'])
160+
expect((wrapper.emitted('hello') as unknown[])[0]).toEqual(['foo', 'bar'])
161161
})
162162

163163
it('captures events emitted by class-style components', () => {
@@ -175,12 +175,12 @@ describe('emitted', () => {
175175

176176
wrapper.find('h1').trigger('click')
177177
expect(wrapper.emitted('hello')).toHaveLength(1)
178-
expect(wrapper.emitted('hello')[0]).toEqual(['foo', 'bar'])
178+
expect((wrapper.emitted('hello') as unknown[])[0]).toEqual(['foo', 'bar'])
179179
})
180180

181181
it('captures an event emitted in setup', () => {
182182
const Comp = {
183-
setup(_, { emit }) {
183+
setup(_: Record<string, any>, { emit }: { emit: SetupContext['emit'] }) {
184184
emit('foo')
185185
}
186186
}

tests/features/async-components.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import { defineAsyncComponent, defineComponent, h, AppConfig } from 'vue'
22

33
import { mount, flushPromises } from '../../src'
4+
import { ComponentPublicInstance } from '@vue/runtime-core'
45

56
const config: AppConfig = {
67
optionMergeStrategies: {},
78
globalProperties: {},
89
isCustomElement: (tag: string) => false,
910
performance: false,
10-
errorHandler: (error: Error) => {
11-
if (error.message.match(/Async component failed to load./)) {
11+
errorHandler: (error: unknown) => {
12+
if ((error as Error).message.match(/Async component failed to load./)) {
1213
return
1314
}
14-
throw error
1515
}
1616
}
1717

tests/functionalComponents.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { mount } from '../src'
2-
import { h } from 'vue'
2+
import { h, Slots } from 'vue'
33
import Hello from './components/Hello.vue'
44

55
describe('functionalComponents', () => {
@@ -17,7 +17,8 @@ describe('functionalComponents', () => {
1717
})
1818

1919
it('renders the slots of a functional component', () => {
20-
const Foo = (props, { slots }) => h('div', { class: 'foo' }, slots)
20+
const Foo = (props: Record<string, any>, { slots }: { slots: Slots }) =>
21+
h('div', { class: 'foo' }, slots)
2122

2223
const wrapper = mount(Foo, {
2324
slots: {
@@ -29,7 +30,7 @@ describe('functionalComponents', () => {
2930
})
3031

3132
it('asserts classes', () => {
32-
const Foo = (props, { slots }) => h('div', { class: 'foo' }, slots)
33+
const Foo = () => h('div', { class: 'foo' })
3334

3435
const wrapper = mount(Foo, {
3536
attrs: {

tests/isVisible.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@ describe('isVisible', () => {
9393
`,
9494
methods: {
9595
add() {
96+
// @ts-expect-error
9697
this.items.push(2)
9798
},
9899
remove() {
100+
// @ts-expect-error
99101
this.items.splice(1) // back to [1]
100102
}
101103
},

tests/lifecycle.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('lifecycles', () => {
5555
expect(onUnmountFn).not.toHaveBeenCalled()
5656

5757
const removeChildSpy = jest.spyOn(
58-
wrapper.element.parentElement,
58+
wrapper.element.parentElement!,
5959
'removeChild'
6060
)
6161

tests/mountingOptions/attachTo.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('options.attachTo', () => {
1717
})
1818

1919
const root = document.getElementById('root')
20-
const rendered = document.getElementById('attach-to')
20+
const rendered = document.getElementById('attach-to')!
2121
expect(wrapper.vm.$el.parentNode).not.toBeNull()
2222
expect(root).not.toBeNull()
2323
expect(rendered).not.toBeNull()
@@ -36,7 +36,7 @@ describe('options.attachTo', () => {
3636
})
3737

3838
const root = document.getElementById('root')
39-
const rendered = document.getElementById('attach-to')
39+
const rendered = document.getElementById('attach-to')!
4040
expect(wrapper.vm.$el.parentNode).not.toBeNull()
4141
expect(root).not.toBeNull()
4242
expect(rendered).not.toBeNull()

tests/mountingOptions/data.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ describe('mounting options: data', () => {
1111
bar: 'bar'
1212
}
1313
},
14-
render() {
14+
render(): Function {
15+
// @ts-expect-error
1516
return h('div', `Foo is ${this.foo} bar is ${this.bar}`)
1617
}
1718
}

0 commit comments

Comments
 (0)