Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ export function setup() {
/**
* Auto initialization.
*/
/* c8 ignore next 18 */
export function init() {
setup();
sampleRUM.collectBaseURL = window.origin;
sampleRUM.collectBaseURL = new URL(`${window.hlx.codeBasePath}/`, window.origin);
sampleRUM();
}
8 changes: 7 additions & 1 deletion test/setup/setup.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
/* eslint-env mocha */
import { runTests } from '@web/test-runner-mocha';
import { expect } from '@esm-bundle/chai';
import { setup } from '../../src/setup.js';
import { sampleRUM } from '@adobe/helix-rum-js';
import { setup, init } from '../../src/setup.js';

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

it('init - sets sampleRUM.collectBaseURL to include the codeBasePath', () => {
init();
expect(sampleRUM.collectBaseURL.href).to.be.equal(`${window.origin}/some/path/`);
});
});
</script>
</body>
Expand Down