remove test code, use mocks instead
This commit is contained in:
@@ -27,6 +27,8 @@ import {
|
||||
Keys,
|
||||
} from '../../test-utils/interactions'
|
||||
|
||||
jest.mock('../../hooks/use-id')
|
||||
|
||||
function getMenuButton(): HTMLElement | null {
|
||||
// This is just an assumption for our tests. We assume that we only have 1 button. And if we have
|
||||
// more, than we assume that it is the first one.
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import * as React from 'react'
|
||||
|
||||
beforeEach(() => {
|
||||
id = 0
|
||||
})
|
||||
|
||||
let id = 0
|
||||
function generateId() {
|
||||
return ++id
|
||||
}
|
||||
|
||||
export function useId() {
|
||||
const [id] = React.useState(generateId)
|
||||
return id
|
||||
}
|
||||
@@ -1,13 +1,5 @@
|
||||
import * as React from 'react'
|
||||
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
if (process.env.JEST_WORKER_ID !== undefined) {
|
||||
beforeEach(() => {
|
||||
id = 0
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
let id = 0
|
||||
function generateId() {
|
||||
return ++id
|
||||
|
||||
@@ -26,6 +26,8 @@ import {
|
||||
word,
|
||||
} from '../../test-utils/interactions'
|
||||
|
||||
jest.mock('../../hooks/use-id')
|
||||
|
||||
function renderTemplate(input: string | Partial<Parameters<typeof defineComponent>[0]>) {
|
||||
const defaultComponents = { Menu, MenuButton, MenuItems, MenuItem }
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
beforeEach(() => {
|
||||
id = 0
|
||||
})
|
||||
|
||||
let id = 0
|
||||
function generateId() {
|
||||
return ++id
|
||||
}
|
||||
|
||||
export function useId() {
|
||||
return generateId()
|
||||
}
|
||||
@@ -1,11 +1,3 @@
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
if (process.env.JEST_WORKER_ID !== undefined) {
|
||||
beforeEach(() => {
|
||||
id = 0
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
let id = 0
|
||||
function generateId() {
|
||||
return ++id
|
||||
|
||||
Reference in New Issue
Block a user