Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions packages/react/transform/__test__/css/inline-style.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,28 @@ import { transformReactLynx } from '../../main.js';

describe('Parse Inline Style', () => {
it('should fallback to SetInlineStyles when have unknown CSS property', async () => {
const { formatMessages } = await import('esbuild');

const result = await transformReactLynx(
`<view style="height:100px;invalid:true;width: 200px"/>`,
);
// Should not have `__AddInlineStyle`
expect(result.code).not.toContain(`__AddInlineStyle`);
// Should have __SetInlineStyles(element, "height:100px;invalid:true;width: 200px")
expect(result.code).toContain('height:100px;invalid:true;width: 200px');
expect(
await formatMessages(result.warnings, { kind: 'warning', color: false }),
).toMatchInlineSnapshot(`[]`);
expect(result.warnings).toEqual([]);
});

it('should fallback to SetInlineStyles when parse CSS value failed', async () => {
const { formatMessages } = await import('esbuild');
const result = await transformReactLynx(
`<view style="height:100px;width: ; ;color: #0f0f0f"/>`,
);
// Should not have `__AddInlineStyle`
expect(result.code).not.toContain(`__AddInlineStyle`);
// Should have __SetInlineStyles(element, "height:100px;width: ; ;color: #0f0f0f")
expect(result.code).toContain('height:100px;width: ; ;color: #0f0f0f');
expect(
await formatMessages(result.warnings, { kind: 'warning', color: false }),
).toMatchInlineSnapshot(`[]`);
expect(result.warnings).toEqual([]);
});

it('should fallback to SetInlineStyles when parse CSS failed', async () => {
const { formatMessages } = await import('esbuild');

const result = await transformReactLynx(
`<view style="?*xxxxxxx;foo bar;"/>`,
);
Expand All @@ -46,8 +37,6 @@ describe('Parse Inline Style', () => {

// Should have __SetInlineStyles(element, "?*xxxxxxx;foo bar;")
expect(result.code).toContain('?*xxxxxxx;foo bar;');
expect(
await formatMessages(result.warnings, { kind: 'warning', color: false }),
).toMatchInlineSnapshot(`[]`);
expect(result.warnings).toEqual([]);
});
});
12 changes: 2 additions & 10 deletions packages/react/transform/__test__/css/object-lit-style.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,6 @@ let jsx = <view style={{ height, width }}/>`,
});

it('should fallback to SetInlineStyles when have unknown CSS property', async () => {
const { formatMessages } = await import('esbuild');

const result = await transformReactLynx(
`<view style={{ width: '100px', invalid: false, height: '200rpx', invalidProperty: 'auto' }}/>`,
);
Expand All @@ -269,14 +267,10 @@ let jsx = <view style={{ height, width }}/>`,
expect(result.code).toContain(`width: '100px'`);
expect(result.code).toContain(`invalid: false`);
expect(result.code).toContain(`height: '200rpx'`);
expect(
await formatMessages(result.warnings, { kind: 'warning', color: false }),
).toMatchInlineSnapshot(`[]`);
expect(result.warnings).toEqual([]);
});

it('should fallback to SetInlineStyles when have computed CSS property', async () => {
const { formatMessages } = await import('esbuild');

const result = await transformReactLynx(
`<view style={{ width: value, [key]: false, height: '200rpx' }}/>`,
);
Expand All @@ -286,8 +280,6 @@ let jsx = <view style={{ height, width }}/>`,
expect(result.code).toContain(`width: value`);
expect(result.code).toContain(`[key]: false`);
expect(result.code).toContain(`height: '200rpx'`);
expect(
await formatMessages(result.warnings, { kind: 'warning', color: false }),
).toMatchInlineSnapshot(`[]`);
expect(result.warnings).toEqual([]);
});
});
Loading
Loading