Skip to content

Commit

Permalink
Improve promise-like extension block test
Browse files Browse the repository at this point in the history
notably, fail on compiler errors, and run the test block several times
  • Loading branch information
GarboMuffin committed Jan 27, 2024
1 parent 696cda7 commit a15c069
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Binary file modified test/fixtures/tw-block-returning-promise-like.sb3
Binary file not shown.
8 changes: 6 additions & 2 deletions test/integration/tw_block_returning_promise_like.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class TestExtension {
};
}
test () {
// returns a PromiseLike that calls handler immediately.
// returns a PromiseLike that calls handler immediately instead of in next microtask.
const promise = {
then (callbackFn) {
callbackFn();
return promise;
}
// intentionally omit catch() as that is not part of PromiseLike
// intentionally omit catch() as that is not part of PromiseLike, so it should not be used
};
return promise;
}
Expand All @@ -45,6 +45,10 @@ for (const compilerEnabled of [false, true]) {
});
t.equal(vm.runtime.compilerOptions.enabled, compilerEnabled, 'sanity check');

vm.runtime.on('COMPILE_ERROR', () => {
t.fail('Compile error');
});

vm.loadProject(fixture).then(() => {
let ended = 0;
vm.runtime.on('SAY', (target, type, text) => {
Expand Down

0 comments on commit a15c069

Please sign in to comment.