Files
Agent-n8n/backups/exhibition-demo-backup-20250928-210916/node_modules/style-to-js/src/index.test.ts
Yep_Q 67f5dfbe50 feat: 实现多订单班支持系统
主要功能:
- 修改RequirementModal支持12个订单班选择
- 添加OrderClassIconMap图标映射组件
- Store中添加selectedOrderClass状态管理
- WorkflowPage支持传递orderClass参数
- web_result添加URL参数切换功能
- 创建order-class-handler.js动态处理页面主题

技术改进:
- 创建软链接关联订单班数据目录
- 生成wenlu.json和food.json数据结构
- 删除重复的web_result目录
- 添加测试页面test-order-class.html

影响范围:
- 展会策划系统现支持12个订单班
- 结果展示页面自动适配不同订单班主题
- 用户可选择不同行业生成对应方案

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-29 10:02:15 +08:00

130 lines
3.7 KiB
TypeScript

import styleToJS = require('.');
it('exposes itself as default', () => {
expect(styleToJS).toBe(styleToJS.default);
});
it('parses empty style to object', () => {
expect(styleToJS('')).toEqual({});
});
it('does not parse CSS comment', () => {
expect(styleToJS('/* comment */')).toEqual({});
});
// invalid argument
it.each([undefined, null, 0, 1, true, false, {}, [], () => {}, new Date()])(
'parses "%s" to empty object',
(text) => {
expect(styleToJS(text as string)).toEqual({});
},
);
it.each(['top:', ':12px', ':', ';'])('parses "%s" to empty object', (text) => {
expect(styleToJS(text)).toEqual({});
});
it('parses common styles to object', () => {
const style = `
color: #f00;
font-size: 42px;
z-index: -1;
`;
expect(styleToJS(style)).toMatchInlineSnapshot(`
{
"color": "#f00",
"fontSize": "42px",
"zIndex": "-1",
}
`);
});
it('parses style with vendor prefix to object', () => {
const style = `
display: -ms-grid;
display: grid;
-webkit-transition: all .5s;
-o-transition: all .5s;
transition: all .5s;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background: -webkit-gradient(linear, left top, left bottom, from(white), to(black));
background: -o-linear-gradient(top, white, black);
background: linear-gradient(to bottom, white, black);
`;
expect(styleToJS(style)).toMatchInlineSnapshot(`
{
"background": "linear-gradient(to bottom, white, black)",
"display": "grid",
"mozUserSelect": "none",
"msUserSelect": "none",
"oTransition": "all .5s",
"transition": "all .5s",
"userSelect": "none",
"webkitTransition": "all .5s",
"webkitUserSelect": "none",
}
`);
});
it('parses background style to object', () => {
const style =
'background: url(data:image/png; base64,ivborw0kggoaaaansaaaabgdbtueaalgpc/xhbqaaaafzmuexurczmzpf399fx1+bm5mzy9avzxbesmgces5/p8/t9furvcrmu73jwlzosgsiizurcjo/ad+eqjjb4hv8bft+idpqocx1wjosbfhh2xssxeiyn3uli/6mnree07uiwjev8u8czwyuqdlkpg1bkb4nnm+veanfhqn1k4+gpt6ugqcvu2h2ovuif)';
expect(styleToJS(style)).toMatchInlineSnapshot(`
{
"background": "url(data:image/png; base64,ivborw0kggoaaaansaaaabgdbtueaalgpc/xhbqaaaafzmuexurczmzpf399fx1+bm5mzy9avzxbesmgces5/p8/t9furvcrmu73jwlzosgsiizurcjo/ad+eqjjb4hv8bft+idpqocx1wjosbfhh2xssxeiyn3uli/6mnree07uiwjev8u8czwyuqdlkpg1bkb4nnm+veanfhqn1k4+gpt6ugqcvu2h2ovuif)",
}
`);
});
it('parses style with no spaces to object', () => {
const style =
'border-bottom-left-radius:1em;border-right-style:solid;Z-Index:-1;-moz-border-radius-bottomleft:20px';
expect(styleToJS(style)).toMatchInlineSnapshot(`
{
"borderBottomLeftRadius": "1em",
"borderRightStyle": "solid",
"mozBorderRadiusBottomleft": "20px",
"zIndex": "-1",
}
`);
});
describe('when option reactCompat is true', () => {
const options = { reactCompat: true };
it('capitalizes vendor prefixes', () => {
const style = `
-khtml-user-select: none;
-moz-user-select: -moz-none;
-o-user-select: none;
-webkit-user-select: none;
user-select: none;
`;
expect(styleToJS(style, options)).toMatchInlineSnapshot(`
{
"KhtmlUserSelect": "none",
"MozUserSelect": "-moz-none",
"OUserSelect": "none",
"WebkitUserSelect": "none",
"userSelect": "none",
}
`);
});
it('does not capitalize ms prefixes', () => {
const style = `
-ms-transform: none;
-ms-user-select: none;
`;
expect(styleToJS(style, options)).toMatchInlineSnapshot(`
{
"msTransform": "none",
"msUserSelect": "none",
}
`);
});
});