Skip to content

Commit

Permalink
test(wtr): test script loading
Browse files Browse the repository at this point in the history
  • Loading branch information
trieloff committed Jun 7, 2024
1 parent d713f25 commit f603f0f
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions test/index.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,17 @@
runTests(async () => {
describe('HTML Index Tests', () => {

it('empty test', () => {
// empty test
console.log('empty test');
});
it('can load rum enhancer as a script', async () => {
let called = false;
window.hlx = {
rum: {
sampleRUM: (...args) => {
console.log('fake sampleRUM', ...args);
called = true;
console.log('fake sampleRUM', ...args, called);
}
}
};

window.hlx.rum.sampleRUM.drain = (...args) => {
console.log('fake drain', ...args);
called = true;
};


const script = document.createElement('script');
script.src = new URL('/src/index.js', window.location).href;
Expand All @@ -39,6 +31,11 @@
await new Promise((resolve) => {
script.onload = resolve;
});
// wait one second for the script to run
await new Promise((resolve) => {
setTimeout(resolve, 1000);
});

expect(called).to.be.true;
});

Expand Down

0 comments on commit f603f0f

Please sign in to comment.