Skip to content

Commit

Permalink
Fix and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Looky1173 committed Aug 24, 2022
1 parent 3b74e2b commit 3881de1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/core/__tests__/hash.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('hash', () => {
const res = hash('compiled', 'target');

expect(toHash).toBeCalledWith('compiled');
expect(update).toBeCalledWith('parse()', 'target', undefined);
expect(update).toBeCalledWith('parse()', 'target', undefined, null);
expect(astish).toBeCalledWith('compiled');
expect(parse).toBeCalledWith('astish()', '.toHash()');

Expand All @@ -53,7 +53,7 @@ describe('hash', () => {
expect(toHash).not.toBeCalled();
expect(astish).not.toBeCalled();
expect(parse).not.toBeCalled();
expect(update).toBeCalledWith('parse()', 'target', undefined);
expect(update).toBeCalledWith('parse()', 'target', undefined, null);

expect(res).toEqual('toHash()');
});
Expand All @@ -64,7 +64,18 @@ describe('hash', () => {
expect(toHash).toBeCalledWith('global');
expect(astish).not.toBeCalled();
expect(parse).not.toBeCalled();
expect(update).toBeCalledWith('parse()', 'target', undefined);
expect(update).toBeCalledWith('parse()', 'target', undefined, null);

expect(res).toEqual('toHash()');
});

it('regression: global-style-replace', () => {
const res = hash('global', 'target', true);

expect(toHash).not.toBeCalled();
expect(astish).not.toBeCalled();
expect(parse).not.toBeCalled();
expect(update).toBeCalledWith('parse()', 'target', undefined, 'parse()');

expect(res).toEqual('toHash()');
});
Expand All @@ -75,7 +86,7 @@ describe('hash', () => {
expect(toHash).toBeCalledWith('keyframes');
expect(astish).not.toBeCalled();
expect(parse).not.toBeCalled();
expect(update).toBeCalledWith('parse()', 'target', undefined);
expect(update).toBeCalledWith('parse()', 'target', undefined, null);

expect(res).toEqual('toHash()');
});
Expand All @@ -89,7 +100,7 @@ describe('hash', () => {
expect(toHash).toBeCalledWith('baz1');
expect(astish).not.toBeCalled();
expect(parse).toBeCalledWith({ baz: 1 }, '.' + className);
expect(update).toBeCalledWith('parse()', 'target', undefined);
expect(update).toBeCalledWith('parse()', 'target', undefined, null);

expect(res).toEqual(className);
});
Expand Down
13 changes: 13 additions & 0 deletions src/core/__tests__/update.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,17 @@ describe('update', () => {
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; }');
});
});

0 comments on commit 3881de1

Please sign in to comment.