2022-04-29 20:19:22 +00:00
|
|
|
import { updateStyle } from '../src/render/style';
|
|
|
|
import {
|
|
|
|
cleanupGlobals,
|
|
|
|
expectedBlock,
|
|
|
|
expectedInline,
|
|
|
|
setupDOM,
|
2022-10-08 10:38:53 +00:00
|
|
|
styleOpeningTag,
|
2022-09-07 18:25:59 +00:00
|
|
|
} from '../src/tests/helpers';
|
2022-04-29 20:19:22 +00:00
|
|
|
|
|
|
|
describe('Testing rendering style', () => {
|
|
|
|
afterEach(cleanupGlobals);
|
|
|
|
|
|
|
|
it('updateStyle', () => {
|
|
|
|
// Setup DOM
|
|
|
|
const doc = setupDOM('').window.document;
|
|
|
|
|
|
|
|
// Create container node
|
|
|
|
const node = doc.createElement('div');
|
|
|
|
|
|
|
|
// Add style to empty parent
|
|
|
|
updateStyle(node, false);
|
2022-10-08 10:38:53 +00:00
|
|
|
expect(node.innerHTML).toBe(
|
|
|
|
styleOpeningTag + expectedBlock + '</style>'
|
|
|
|
);
|
2022-04-29 20:19:22 +00:00
|
|
|
|
|
|
|
// Change inline mode
|
|
|
|
updateStyle(node, true);
|
2022-10-08 10:38:53 +00:00
|
|
|
expect(node.innerHTML).toBe(
|
|
|
|
styleOpeningTag + expectedInline + '</style>'
|
|
|
|
);
|
2022-04-29 20:19:22 +00:00
|
|
|
|
|
|
|
// Do not change anything
|
|
|
|
updateStyle(node, true);
|
2022-10-08 10:38:53 +00:00
|
|
|
expect(node.innerHTML).toBe(
|
|
|
|
styleOpeningTag + expectedInline + '</style>'
|
|
|
|
);
|
2022-04-29 20:19:22 +00:00
|
|
|
|
|
|
|
// Change to block
|
|
|
|
updateStyle(node, false);
|
2022-10-08 10:38:53 +00:00
|
|
|
expect(node.innerHTML).toBe(
|
|
|
|
styleOpeningTag + expectedBlock + '</style>'
|
|
|
|
);
|
2022-04-29 20:19:22 +00:00
|
|
|
});
|
|
|
|
});
|