ice/packages/rax-compat/tests/props.test.tsx

55 lines
1.2 KiB
TypeScript
Raw Normal View History

Feat/define data loader (#643) * feat: modify dataLoader * feat: add type * feat: add DataLoaderConfig * feat: modify getData to defineDataLoader * chore: remove defineDataLoader * fix: fetcher shoule return promise * fix: loader may be undefined * fix: err loader config * chore: modify example of pha * feat: modify getData * chore: modify type and mofiy options of init * feat: modify fetcher to dataLoaderFetcher and add dataLoaderImport to entry * chore: modify defaultDataLoaderFetcher * chore: load data by route id * feat: modify serverDataLoader and staticDataLoader * feat: add fetcher when route change * fix: deal with window undefined * chore: modify type * feat: try get data from cache * feat: support useData * feat: add defineStaticDataLoader and defineServerDataLoader * chore: modify getData of example * fix: should load data * fix: fix ssg err * fix: fix dataloader for ssg * test: modify env of test * fix: shoule clear cache when route changed * fix: fix renderMode and add defult remder mode * fix: add window * test: add jsdom * test: modify getData to dataLoader * test: modify test of clientApp * test: clear window after each test * test: remove only * test: remove only * chore: modify appear * fix: Try get data from cache when CSR * chore: update lock * chore: remove unused * refactor: data loader (#685) * refactor: set global fetcher * refactor: set global fetcher * fix: should not build react in data loader * fix: test * test: modify test Co-authored-by: 水澜 <shuilan.cj@taobao.com> Co-authored-by: ZeroLing <i@zeroling.com>
2022-11-14 15:59:22 +08:00
/**
* @vitest-environment jsdom
*/
import { expect, it, describe } from 'vitest';
import transformProps from '../src/props';
describe('props', () => {
it('should work with autofocus', () => {
expect(transformProps('div', {
autofocus: true,
}).autoFocus).toBe(true);
});
it('should work with autoplay', () => {
expect(transformProps('div', {
autoplay: true,
}).autoPlay).toBe(true);
});
it('should work with classname', () => {
expect(transformProps('div', {
classname: 'class',
}).className).toBe('class');
});
it('should work with crossorigin', () => {
expect(transformProps('div', {
crossorigin: 'xxx',
}).crossOrigin).toBe('xxx');
});
it('should work with maxlength', () => {
expect(transformProps('div', {
maxlength: '10',
}).maxLength).toBe('10');
});
it('should work with inputmode', () => {
expect(transformProps('div', {
inputmode: 'numeric',
}).inputMode).toBe('numeric');
});
2024-05-10 10:13:51 +08:00
it('should work with dangerouslySetInnerHTML', () => {
expect(
transformProps('div', {
2024-05-10 10:13:51 +08:00
dangerouslySetInnerHTML: { __html: 'xxx' },
}).dangerouslySetInnerHTML,
).toEqual({
__html: 'xxx',
});
});
});