更新deno.json和deno.lock文件,调整依赖项版本并添加开发模式标识,确保与最新的库版本兼容,提升项目的可维护性和稳定性。
This commit is contained in:
61
client/admin/test/theme_setting_page.test.tsx
Normal file
61
client/admin/test/theme_setting_page.test.tsx
Normal file
@@ -0,0 +1,61 @@
|
||||
import { JSDOM } from 'npm:jsdom'
|
||||
import React from 'react'
|
||||
import {render, fireEvent, within, screen} from '@testing-library/react'
|
||||
import { ThemeSettingsPage } from "../pages_settings.tsx"
|
||||
import { ThemeProvider } from "../hooks_sys.tsx"
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
|
||||
const queryClient = new QueryClient()
|
||||
|
||||
|
||||
const dom = new JSDOM(`<body></body>`, { runScripts: "dangerously" , pretendToBeVisual: true });
|
||||
|
||||
// The script will be executed and modify the DOM:
|
||||
// console.log(dom.window.document.getElementById("root").innerHTML); // 1
|
||||
globalThis.window = dom.window;
|
||||
globalThis.document = dom.window.document;
|
||||
const customScreen = within(document.body)
|
||||
|
||||
// console.log(dom.window.document.getElementById("root").innerHTML); // 1
|
||||
// const div = globalThis.document.createElement("div");
|
||||
// div.innerHTML = "主题设置";
|
||||
// globalThis.document.getElementById("root")?.appendChild(div);
|
||||
|
||||
// render(<TestNode />);
|
||||
|
||||
// const testMessage = 'Test Message'
|
||||
// render(<HiddenMessage>{testMessage}</HiddenMessage>)
|
||||
// console.log('document.body.innerHTML', document.body.innerHTML);
|
||||
// const customScreen = within(document.body)
|
||||
|
||||
// screen.debug()
|
||||
|
||||
// // // query* functions will return the element or null if it cannot be found
|
||||
// // // get* functions will return the element or throw an error if it cannot be found
|
||||
// console.log('queryByText', customScreen.queryByText(testMessage))
|
||||
|
||||
// // // the queries can accept a regex to make your selectors more resilient to content tweaks and changes.
|
||||
// fireEvent.click(customScreen.getByLabelText(/show/i))
|
||||
|
||||
// screen.debug()
|
||||
|
||||
// // // .toBeInTheDocument() is an assertion that comes from jest-dom
|
||||
// // // otherwise you could use .toBeDefined()
|
||||
// console.log('getByText', customScreen.getByText(testMessage).innerHTML.includes(testMessage))
|
||||
|
||||
// // console.log(globalThis.document.body.innerHTML);
|
||||
// // console.log(screen.debug());
|
||||
// // screen.findByText("主题设置");
|
||||
|
||||
render((
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<ThemeProvider>
|
||||
<ThemeSettingsPage />
|
||||
</ThemeProvider>
|
||||
</QueryClientProvider>
|
||||
))
|
||||
|
||||
screen.debug()
|
||||
|
||||
// screen.findByText("主题设置")
|
||||
|
||||
Reference in New Issue
Block a user