Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
Fix esbuild tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelMunoz committed Apr 28, 2023
1 parent 35f1232 commit 74cb2d1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion tests/Perla.Tests/Build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ module Build =
let parser = browserCtx.GetService<IHtmlParser>()
let document = parser.ParseDocument baseIndex

let css, js = Build.GetEntryPoints(document)
let css, js, _ = Build.GetEntryPoints(document)

let url = Assert.Single(css)
Assert.Equal("./src/app-styles.css", url)
Expand Down
38 changes: 20 additions & 18 deletions tests/Perla.Tests/Esbuild.fs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,12 @@ const a = /* @__PURE__ */ jsx("a", { children: b });

[<Fact>]
member _.``Esbuild Plugin should process Typescript``() = task {
let plugin =
Esbuild.GetPlugin(
{
Defaults.EsbuildConfig with
minify = false
}
)
let config = {
Defaults.EsbuildConfig with
minify = false
}

let plugin = Esbuild.GetPlugin(config)

match plugin.transform with
| ValueSome transform ->
Expand All @@ -106,8 +105,10 @@ const a = /* @__PURE__ */ jsx("a", { children: b });
Assert.Equal(".js", result.extension)

Assert.Equal(
"""const b = "hello";
const a = (msg) => console.log(msg);
"""var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
const b = "hello";
const a = /* @__PURE__ */ __name((msg) => console.log(msg), "a");
a(b);
""",
result.content
Expand All @@ -117,14 +118,13 @@ a(b);

[<Fact>]
member _.``Esbuild Plugin should process Javascript``() = task {
let plugin =
Esbuild.GetPlugin(
{
Defaults.EsbuildConfig with
minify = false
ecmaVersion = "es2016"
}
)
let config = {
Defaults.EsbuildConfig with
minify = false
ecmaVersion = "es2016"
}

let plugin = Esbuild.GetPlugin(config)

match plugin.transform with
| ValueSome transform ->
Expand All @@ -138,7 +138,9 @@ a(b);
Assert.Equal(".js", result.extension)

Assert.Equal(
"""const a = (msg2) => console.log(msg2 != null ? msg2 : "no message");
"""var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
const a = /* @__PURE__ */ __name((msg2) => console.log(msg2 != null ? msg2 : "no message"), "a");
a(msg);
""",
result.content
Expand Down

0 comments on commit 74cb2d1

Please sign in to comment.