- 收敛 easyflow-ui-admin 的 lint、格式和类型问题 - 修正 demo 页面与管理端前端构建失败点 - 验证 pnpm lint 与 pnpm build 均已通过
71 lines
1.9 KiB
TypeScript
71 lines
1.9 KiB
TypeScript
import { beforeEach, describe, expect, it } from 'vitest';
|
|
|
|
import { componentName } from './consts';
|
|
import { Tinyflow } from './Tinyflow';
|
|
|
|
describe('tinyflow theme', () => {
|
|
beforeEach(() => {
|
|
document.body.innerHTML = '';
|
|
});
|
|
|
|
it('should use light theme by default', () => {
|
|
const container = document.createElement('div');
|
|
document.body.append(container);
|
|
|
|
const tinyflow = new Tinyflow({
|
|
element: container,
|
|
});
|
|
|
|
const tinyflowEl = container.querySelector(componentName);
|
|
expect(tinyflowEl).toBeTruthy();
|
|
expect(tinyflowEl?.classList.contains('tf-theme-light')).toBe(true);
|
|
expect(tinyflowEl?.classList.contains('tf-theme-dark')).toBe(false);
|
|
|
|
tinyflow.destroy();
|
|
});
|
|
|
|
it('should toggle theme class without remount', () => {
|
|
const container = document.createElement('div');
|
|
document.body.append(container);
|
|
|
|
const tinyflow = new Tinyflow({
|
|
element: container,
|
|
theme: 'dark',
|
|
});
|
|
|
|
const tinyflowEl = container.querySelector(componentName);
|
|
expect(tinyflowEl?.classList.contains('tf-theme-dark')).toBe(true);
|
|
|
|
tinyflow.setTheme('light');
|
|
|
|
expect(tinyflowEl?.classList.contains('tf-theme-light')).toBe(true);
|
|
expect(tinyflowEl?.classList.contains('tf-theme-dark')).toBe(false);
|
|
|
|
tinyflow.destroy();
|
|
});
|
|
|
|
it('should keep theme when data is reset', () => {
|
|
const container = document.createElement('div');
|
|
document.body.append(container);
|
|
|
|
const tinyflow = new Tinyflow({
|
|
element: container,
|
|
theme: 'dark',
|
|
});
|
|
|
|
const firstRenderEl = container.querySelector(componentName);
|
|
tinyflow.setData({
|
|
nodes: [],
|
|
edges: [],
|
|
});
|
|
const secondRenderEl = container.querySelector(componentName);
|
|
|
|
expect(firstRenderEl).toBeTruthy();
|
|
expect(secondRenderEl).toBeTruthy();
|
|
expect(secondRenderEl).not.toBe(firstRenderEl);
|
|
expect(secondRenderEl?.classList.contains('tf-theme-dark')).toBe(true);
|
|
|
|
tinyflow.destroy();
|
|
});
|
|
});
|