fix: 修复管理端前端 lint 与构建问题
- 收敛 easyflow-ui-admin 的 lint、格式和类型问题 - 修正 demo 页面与管理端前端构建失败点 - 验证 pnpm lint 与 pnpm build 均已通过
This commit is contained in:
@@ -1,70 +1,70 @@
|
||||
import {beforeEach, describe, expect, it} from 'vitest';
|
||||
import { beforeEach, describe, expect, it } from 'vitest';
|
||||
|
||||
import {componentName} from './consts';
|
||||
import {Tinyflow} from './Tinyflow';
|
||||
import { componentName } from './consts';
|
||||
import { Tinyflow } from './Tinyflow';
|
||||
|
||||
describe('tinyflow theme', () => {
|
||||
beforeEach(() => {
|
||||
document.body.innerHTML = '';
|
||||
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,
|
||||
});
|
||||
|
||||
it('should use light theme by default', () => {
|
||||
const container = document.createElement('div');
|
||||
document.body.append(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);
|
||||
|
||||
const tinyflow = new Tinyflow({
|
||||
element: container
|
||||
});
|
||||
tinyflow.destroy();
|
||||
});
|
||||
|
||||
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);
|
||||
it('should toggle theme class without remount', () => {
|
||||
const container = document.createElement('div');
|
||||
document.body.append(container);
|
||||
|
||||
tinyflow.destroy();
|
||||
const tinyflow = new Tinyflow({
|
||||
element: container,
|
||||
theme: 'dark',
|
||||
});
|
||||
|
||||
it('should toggle theme class without remount', () => {
|
||||
const container = document.createElement('div');
|
||||
document.body.append(container);
|
||||
const tinyflowEl = container.querySelector(componentName);
|
||||
expect(tinyflowEl?.classList.contains('tf-theme-dark')).toBe(true);
|
||||
|
||||
const tinyflow = new Tinyflow({
|
||||
element: container,
|
||||
theme: 'dark'
|
||||
});
|
||||
tinyflow.setTheme('light');
|
||||
|
||||
const tinyflowEl = container.querySelector(componentName);
|
||||
expect(tinyflowEl?.classList.contains('tf-theme-dark')).toBe(true);
|
||||
expect(tinyflowEl?.classList.contains('tf-theme-light')).toBe(true);
|
||||
expect(tinyflowEl?.classList.contains('tf-theme-dark')).toBe(false);
|
||||
|
||||
tinyflow.setTheme('light');
|
||||
tinyflow.destroy();
|
||||
});
|
||||
|
||||
expect(tinyflowEl?.classList.contains('tf-theme-light')).toBe(true);
|
||||
expect(tinyflowEl?.classList.contains('tf-theme-dark')).toBe(false);
|
||||
it('should keep theme when data is reset', () => {
|
||||
const container = document.createElement('div');
|
||||
document.body.append(container);
|
||||
|
||||
tinyflow.destroy();
|
||||
const tinyflow = new Tinyflow({
|
||||
element: container,
|
||||
theme: 'dark',
|
||||
});
|
||||
|
||||
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();
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user