Files
NapCatQQ/.pnpm-store/v3/files/89/a16fc336c14272be5cfe2766960aae3dbeae75daa5e1bb4e864102476acc847adec4b22e26c940fbb782201866f93a9e8229df8ef81f5b6524508777109be0
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

65 lines
1.8 KiB
Plaintext

import { update, extractCss } from '../update';
import { getSheet } from '../get-sheet';
describe('update', () => {
it('regression', () => {
const t = { data: '' };
update('css', t);
expect(t.data).toEqual('css');
});
it('regression: duplicate', () => {
const t = { data: '' };
update('css', t);
update('foo', t);
update('css', t);
expect(t.data).toEqual('cssfoo');
});
it('regression: extract and flush', () => {
update('filled', getSheet());
expect(extractCss()).toEqual(' filled');
expect(extractCss()).toEqual('');
});
it('regression: extract and flush without DOM', () => {
const bkp = global.self;
delete global.self;
update('filled', getSheet());
expect(extractCss()).toEqual('filled');
expect(extractCss()).toEqual('');
global.self = bkp;
});
it('regression: extract and flush from custom target', () => {
const target = document.createElement('div');
update('filled', getSheet());
update('filledbody', getSheet(target));
expect(extractCss(target)).toEqual(' filledbody');
expect(extractCss(target)).toEqual('');
});
it('regression: append or prepend', () => {
extractCss();
update('end', getSheet());
update('start', getSheet(), true);
expect(extractCss()).toEqual('startend');
});
it('regression: global style replacement', () => {
const t = { data: 'html, body { background-color: white; }' };
update(
'html, body { background-color: black; }',
t,
undefined,
'html, body { background-color: white; }'
);
expect(t.data).toEqual('html, body { background-color: black; }');
});
});