diff options
Diffstat (limited to 'test/bun.js/plugins.test.ts')
-rw-r--r-- | test/bun.js/plugins.test.ts | 70 |
1 files changed, 24 insertions, 46 deletions
diff --git a/test/bun.js/plugins.test.ts b/test/bun.js/plugins.test.ts index 1d0b0821a..e533cef06 100644 --- a/test/bun.js/plugins.test.ts +++ b/test/bun.js/plugins.test.ts @@ -44,10 +44,7 @@ plugin({ path, namespace: "fail", })); - builder.onLoad( - { filter: /.*/, namespace: "fail" }, - () => globalThis.failingObject, - ); + builder.onLoad({ filter: /.*/, namespace: "fail" }, () => globalThis.failingObject); }, }); @@ -95,20 +92,17 @@ plugin({ path, })); globalThis.asyncObject = {}; - builder.onLoad( - { filter: /.*/, namespace: "async-obj" }, - async ({ path }) => { - await Promise.resolve(1); - return new Promise((resolve, reject) => { - setTimeout(() => { - resolve({ - exports: (globalThis.asyncObject ||= {}), - loader: "object", - }); - }, 1); - }); - }, - ); + builder.onLoad({ filter: /.*/, namespace: "async-obj" }, async ({ path }) => { + await Promise.resolve(1); + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve({ + exports: (globalThis.asyncObject ||= {}), + loader: "object", + }); + }, 1); + }); + }); builder.onResolve({ filter: /.*/, namespace: "asyncfail" }, ({ path }) => ({ namespace: "asyncfail", @@ -116,14 +110,11 @@ plugin({ })); globalThis.asyncfail = false; - builder.onLoad( - { filter: /.*/, namespace: "asyncfail" }, - async ({ path }) => { - await Promise.resolve(1); - await 1; - throw globalThis.asyncfail; - }, - ); + builder.onLoad({ filter: /.*/, namespace: "asyncfail" }, async ({ path }) => { + await Promise.resolve(1); + await 1; + throw globalThis.asyncfail; + }); builder.onResolve({ filter: /.*/, namespace: "asyncret" }, ({ path }) => ({ namespace: "asyncret", @@ -131,14 +122,11 @@ plugin({ })); globalThis.asyncret = 123; - builder.onLoad( - { filter: /.*/, namespace: "asyncret" }, - async ({ path }) => { - await 100; - await Promise.resolve(10); - return await globalThis.asyncret; - }, - ); + builder.onLoad({ filter: /.*/, namespace: "asyncret" }, async ({ path }) => { + await 100; + await Promise.resolve(10); + return await globalThis.asyncret; + }); }, }); @@ -213,12 +201,7 @@ export default Hello; describe("errors", () => { it("valid loaders work", () => { const validLoaders = ["js", "jsx", "ts", "tsx"]; - const inputs = [ - "export default 'hi';", - "export default 'hi';", - "export default 'hi';", - "export default 'hi';", - ]; + const inputs = ["export default 'hi';", "export default 'hi';", "export default 'hi';", "export default 'hi';"]; for (let i = 0; i < validLoaders.length; i++) { const loader = validLoaders[i]; const input = inputs[i]; @@ -229,12 +212,7 @@ describe("errors", () => { it("invalid loaders throw", () => { const invalidLoaders = ["blah", "blah2", "blah3", "blah4"]; - const inputs = [ - "body { background: red; }", - "<h1>hi</h1>", - '{"hi": "there"}', - "hi", - ]; + const inputs = ["body { background: red; }", "<h1>hi</h1>", '{"hi": "there"}', "hi"]; for (let i = 0; i < invalidLoaders.length; i++) { const loader = invalidLoaders[i]; const input = inputs[i]; |