Skip to content

Commit

Permalink
test: add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ramboz committed Oct 5, 2024
1 parent cc31e7c commit 900a728
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/setup/setup.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/* eslint-env mocha */
import { runTests } from '@web/test-runner-mocha';
import { expect } from '@esm-bundle/chai';
import { setup } from '../../src/setup.js';
import { setup, init } from '../../src/setup.js';

runTests(() => {
it('setup - defines window.hlx', () => {
Expand All @@ -33,6 +33,14 @@
expect(window.hlx.codeBasePath).to.be.equal('/some/path');
expect(window.hlx.lighthouse).to.be.false;
});

it('init - does not enable RUM during prerendering', () => {
Object.defineProperty(document, 'prerendering', { value: true });
init();
expect(window.hlx.rum).to.be.undefined;
document.dispatchEvent(new Event('prerenderingchange'));
expect(window.hlx.rum).to.not.be.undefined;
});
});
</script>
</body>
Expand Down

0 comments on commit 900a728

Please sign in to comment.