Files
wehub-resource-sync 2d398e1894
Deploy Github Pages / deploy (push) Failing after 1s
chore: import upstream snapshot with attribution
2026-07-13 12:30:43 +08:00

46 lines
2.0 KiB
TypeScript

import { propDataToKeyValueString } from '../src/helpers';
describe('prototype helpers', () => {
it('propDataToKeyValueString', () => {
// basic
expect(propDataToKeyValueString({ name: 'foo', initValue: 'bar' })).toEqual('foo="bar"');
expect(propDataToKeyValueString({ name: 'foo', initValue: 1 })).toEqual('foo={1}');
expect(propDataToKeyValueString({ name: 'foo', initValue: false })).toEqual('foo={false}');
expect(propDataToKeyValueString({ name: 'foo', initValue: null })).toEqual('foo={null}');
expect(propDataToKeyValueString({ name: 'foo', initValue: [] })).toEqual('foo={[]}');
expect(propDataToKeyValueString({ name: 'foo', initValue: {} })).toEqual('foo={{}}');
expect(propDataToKeyValueString({ name: 'foo', initValue: () => {} })).toEqual(
'foo={() => {}}',
);
expect(propDataToKeyValueString({ name: 'foo', initValue: { foo: 'bar' } })).toEqual(
'foo={{ foo: "bar" }}',
);
expect(propDataToKeyValueString({ name: 'foo', initValue: [{ foo: 'bar' }] })).toEqual(
'foo={[{ foo: "bar" }]}',
);
// wrapped code
expect(
propDataToKeyValueString({ name: 'foo', initValue: '{{<Placeholder text="放置替换" />}}' }),
).toEqual('foo={<Placeholder text="放置替换" />}');
expect(propDataToKeyValueString({ name: 'foo', initValue: '{{tango}}' })).toEqual(
'foo={tango}',
);
expect(propDataToKeyValueString({ name: 'foo', initValue: '{{"bar"}}' })).toEqual(
'foo={"bar"}',
);
expect(propDataToKeyValueString({ name: 'foo', initValue: '{{() => {}}}' })).toEqual(
'foo={() => {}}',
);
// compatible with old version
expect(propDataToKeyValueString({ name: 'foo', initValue: '{() => {}}' })).toEqual(
'foo={() => {}}',
);
expect(
propDataToKeyValueString({ name: 'foo', initValue: '{<Placeholder text="放置替换" />}' }),
).toEqual('foo={<Placeholder text="放置替换" />}');
// expect(propDataToKeyValueString({ name: 'foo', initValue: '{tango}' })).toEqual('foo={tango}');
});
});