@alloy-js/core 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/src/binder.js +33 -2
- package/dist/src/code.js +1 -2
- package/dist/src/components/Block.js +2 -5
- package/dist/src/components/Declaration.js +2 -4
- package/dist/src/components/For.d.ts +1 -1
- package/dist/src/components/For.d.ts.map +1 -1
- package/dist/src/components/For.js +1 -2
- package/dist/src/components/Indent.js +2 -4
- package/dist/src/components/List.js +2 -5
- package/dist/src/components/MemberDeclaration.js +2 -4
- package/dist/src/components/MemberName.js +1 -2
- package/dist/src/components/MemberScope.js +2 -4
- package/dist/src/components/Name.js +1 -2
- package/dist/src/components/Output.js +2 -4
- package/dist/src/components/Prose.js +1 -2
- package/dist/src/components/ReferenceOrContent.d.ts +8 -0
- package/dist/src/components/ReferenceOrContent.d.ts.map +1 -0
- package/dist/src/components/ReferenceOrContent.js +11 -0
- package/dist/src/components/Scope.js +2 -4
- package/dist/src/components/Show.js +1 -2
- package/dist/src/components/SourceDirectory.js +2 -4
- package/dist/src/components/SourceFile.js +2 -5
- package/dist/src/components/StatementList.js +2 -4
- package/dist/src/components/Switch.d.ts +1 -1
- package/dist/src/components/Switch.d.ts.map +1 -1
- package/dist/src/components/Switch.js +1 -2
- package/dist/src/components/Wrap.js +2 -4
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +2 -2
- package/dist/src/components/stc/index.d.ts +1 -0
- package/dist/src/components/stc/index.d.ts.map +1 -1
- package/dist/src/components/stc/index.js +2 -2
- package/dist/src/components/stc/sti.js +1 -2
- package/dist/src/context/assignment.js +1 -2
- package/dist/src/context/binder.js +1 -2
- package/dist/src/context/declaration.js +1 -2
- package/dist/src/context/index.js +1 -2
- package/dist/src/context/member-declaration.js +1 -2
- package/dist/src/context/member-scope.js +1 -2
- package/dist/src/context/name-policy.js +1 -2
- package/dist/src/context/scope.js +1 -2
- package/dist/src/context/source-directory.js +1 -2
- package/dist/src/context/source-file.js +1 -2
- package/dist/src/context.js +1 -2
- package/dist/src/debug.js +13 -15
- package/dist/src/index.browser.js +1 -2
- package/dist/src/index.js +1 -2
- package/dist/src/jsx-runtime.d.ts +1 -1
- package/dist/src/jsx-runtime.d.ts.map +1 -1
- package/dist/src/jsx-runtime.js +1 -2
- package/dist/src/name-policy.js +1 -2
- package/dist/src/refkey.js +1 -2
- package/dist/src/render.js +1 -2
- package/dist/src/slot.js +1 -2
- package/dist/src/stc.js +1 -2
- package/dist/src/sti.js +1 -2
- package/dist/src/tap.js +1 -2
- package/dist/src/tsdoc-metadata.json +1 -1
- package/dist/src/utils.js +2 -4
- package/dist/src/write-output.browser.js +1 -2
- package/dist/src/write-output.js +1 -2
- package/dist/test/browser-build.test.js +85 -0
- package/dist/test/children.test.js +27 -0
- package/dist/test/components/block.test.js +45 -0
- package/dist/test/components/declaration.test.js +30 -0
- package/dist/test/components/list.test.js +86 -0
- package/dist/test/components/prose.test.js +25 -0
- package/dist/test/components/reference-or-content.test.d.ts +2 -0
- package/dist/test/components/reference-or-content.test.d.ts.map +1 -0
- package/dist/test/components/reference-or-content.test.js +149 -0
- package/dist/test/components/slot.test.js +134 -0
- package/dist/test/components/source-file.test.js +64 -0
- package/dist/test/components/wrap.test.js +35 -0
- package/dist/test/control-flow/for.test.js +185 -0
- package/dist/test/control-flow/match.test.js +67 -0
- package/dist/test/control-flow/show.test.js +29 -0
- package/dist/test/name-policy.test.js +19 -0
- package/dist/test/props-with-defaults.test.js +93 -0
- package/dist/test/reactivity/cleanup.test.js +77 -0
- package/dist/test/reactivity/memo.test.js +16 -0
- package/dist/test/reactivity/ref-rendering.test.js +37 -0
- package/dist/test/reactivity/test.test.js +61 -0
- package/dist/test/reactivity/untrack.test.js +23 -0
- package/dist/test/refkey.test.js +25 -0
- package/dist/test/rendering/basic.test.js +96 -0
- package/dist/test/rendering/code.test.js +55 -0
- package/dist/test/rendering/formatting.test.js +402 -0
- package/dist/test/rendering/indent.test.js +90 -0
- package/dist/test/rendering/memoization.test.js +25 -0
- package/dist/test/rendering/refkeys.test.js +32 -0
- package/dist/test/split-props.test.js +77 -0
- package/dist/test/stc.test.js +34 -0
- package/dist/test/symbols.test.js +504 -0
- package/dist/test/utils.test.js +221 -0
- package/dist/testing/extend-expect.js +1 -2
- package/dist/testing/index.js +1 -2
- package/dist/testing/render.js +1 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -22
- package/src/components/For.tsx +2 -2
- package/src/components/ReferenceOrContent.tsx +22 -0
- package/src/components/index.tsx +1 -0
- package/src/components/stc/index.ts +1 -0
- package/src/debug.ts +12 -13
- package/src/jsx-runtime.ts +2 -2
- package/temp/api.json +208 -7
- package/test/components/reference-or-content.test.tsx +138 -0
- package/babel.config.cjs +0 -4
- package/dist/src/binder.js.map +0 -1
- package/dist/src/code.js.map +0 -1
- package/dist/src/components/Block.js.map +0 -1
- package/dist/src/components/Declaration.js.map +0 -1
- package/dist/src/components/For.js.map +0 -1
- package/dist/src/components/Indent.js.map +0 -1
- package/dist/src/components/List.js.map +0 -1
- package/dist/src/components/MemberDeclaration.js.map +0 -1
- package/dist/src/components/MemberName.js.map +0 -1
- package/dist/src/components/MemberScope.js.map +0 -1
- package/dist/src/components/Name.js.map +0 -1
- package/dist/src/components/Output.js.map +0 -1
- package/dist/src/components/Prose.js.map +0 -1
- package/dist/src/components/Scope.js.map +0 -1
- package/dist/src/components/Show.js.map +0 -1
- package/dist/src/components/SourceDirectory.js.map +0 -1
- package/dist/src/components/SourceFile.js.map +0 -1
- package/dist/src/components/StatementList.js.map +0 -1
- package/dist/src/components/Switch.js.map +0 -1
- package/dist/src/components/Wrap.js.map +0 -1
- package/dist/src/components/index.js.map +0 -1
- package/dist/src/components/stc/index.js.map +0 -1
- package/dist/src/components/stc/sti.js.map +0 -1
- package/dist/src/context/assignment.js.map +0 -1
- package/dist/src/context/binder.js.map +0 -1
- package/dist/src/context/declaration.js.map +0 -1
- package/dist/src/context/index.js.map +0 -1
- package/dist/src/context/member-declaration.js.map +0 -1
- package/dist/src/context/member-scope.js.map +0 -1
- package/dist/src/context/name-policy.js.map +0 -1
- package/dist/src/context/scope.js.map +0 -1
- package/dist/src/context/source-directory.js.map +0 -1
- package/dist/src/context/source-file.js.map +0 -1
- package/dist/src/context.js.map +0 -1
- package/dist/src/debug.js.map +0 -1
- package/dist/src/index.browser.js.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/jsx-runtime.js.map +0 -1
- package/dist/src/name-policy.js.map +0 -1
- package/dist/src/refkey.js.map +0 -1
- package/dist/src/render.js.map +0 -1
- package/dist/src/slot.js.map +0 -1
- package/dist/src/stc.js.map +0 -1
- package/dist/src/sti.js.map +0 -1
- package/dist/src/tap.js.map +0 -1
- package/dist/src/utils.js.map +0 -1
- package/dist/src/write-output.browser.js.map +0 -1
- package/dist/src/write-output.js.map +0 -1
- package/dist/testing/extend-expect.js.map +0 -1
- package/dist/testing/index.js.map +0 -1
- package/dist/testing/render.js.map +0 -1
- package/dist/testing/vitest.d.js.map +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { ref } from "@vue/reactivity";
|
|
3
|
+
import { expect, it } from "vitest";
|
|
4
|
+
it("doesn't recalculate when dependencies don't change", () => {
|
|
5
|
+
const signal = ref(0);
|
|
6
|
+
let callCount = 0;
|
|
7
|
+
const m = memo(() => {
|
|
8
|
+
callCount += 1;
|
|
9
|
+
return signal.value;
|
|
10
|
+
});
|
|
11
|
+
expect(callCount).toBe(1);
|
|
12
|
+
m();
|
|
13
|
+
expect(callCount).toBe(1);
|
|
14
|
+
m();
|
|
15
|
+
expect(callCount).toBe(1);
|
|
16
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { code, memo, printTree, renderTree } from "@alloy-js/core";
|
|
2
|
+
import { ref } from "@vue/reactivity";
|
|
3
|
+
import { expect, it } from "vitest";
|
|
4
|
+
it("handles refs in the tree", () => {
|
|
5
|
+
const r = ref(42);
|
|
6
|
+
const tree = renderTree(["The number is ", r]);
|
|
7
|
+
expect(printTree(tree)).toBe("The number is 42");
|
|
8
|
+
r.value = 12;
|
|
9
|
+
expect(printTree(tree)).toBe("The number is 12");
|
|
10
|
+
});
|
|
11
|
+
it("handles refs in the tree with code", () => {
|
|
12
|
+
const r = ref(42);
|
|
13
|
+
const tree = renderTree(code`
|
|
14
|
+
The number is ${r}
|
|
15
|
+
`);
|
|
16
|
+
expect(printTree(tree)).toBe("The number is 42");
|
|
17
|
+
r.value = 12;
|
|
18
|
+
expect(printTree(tree)).toBe("The number is 12");
|
|
19
|
+
});
|
|
20
|
+
it("handles memos in the tree", () => {
|
|
21
|
+
const r = ref(42);
|
|
22
|
+
const m = memo(() => r.value + 10);
|
|
23
|
+
const tree = renderTree(["The number is ", m]);
|
|
24
|
+
expect(printTree(tree)).toBe("The number is 52");
|
|
25
|
+
r.value = 12;
|
|
26
|
+
expect(printTree(tree)).toBe("The number is 22");
|
|
27
|
+
});
|
|
28
|
+
it("handles memos in the tree with code", () => {
|
|
29
|
+
const r = ref(42);
|
|
30
|
+
const m = memo(() => r.value + 10);
|
|
31
|
+
const tree = renderTree(code`
|
|
32
|
+
The number is ${m}
|
|
33
|
+
`);
|
|
34
|
+
expect(printTree(tree)).toBe("The number is 52");
|
|
35
|
+
r.value = 12;
|
|
36
|
+
expect(printTree(tree)).toBe("The number is 22");
|
|
37
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { memo, printTree, renderTree } from "@alloy-js/core";
|
|
3
|
+
import { computed, reactive, ref } from "@vue/reactivity";
|
|
4
|
+
import { expect, it } from "vitest";
|
|
5
|
+
import { mapJoin } from "../../src/utils.js";
|
|
6
|
+
import { d } from "../../testing/render.js";
|
|
7
|
+
it("splices in new nodes", () => {
|
|
8
|
+
const r = ref(["one"]);
|
|
9
|
+
const mapped = computed(() => {
|
|
10
|
+
return r.value.map(v => `mapped ${v}`).join(" ");
|
|
11
|
+
});
|
|
12
|
+
function Foo() {
|
|
13
|
+
return [_$memo(() => mapped.value), " done"];
|
|
14
|
+
}
|
|
15
|
+
const tree = renderTree(_$createComponent(Foo, {}));
|
|
16
|
+
expect(printTree(tree)).toEqual("mapped one done");
|
|
17
|
+
r.value = [...r.value, "two"];
|
|
18
|
+
expect(printTree(tree)).toEqual("mapped one mapped two done");
|
|
19
|
+
});
|
|
20
|
+
it("works with a complex case", () => {
|
|
21
|
+
const importRecords = reactive(new Map());
|
|
22
|
+
function addImport(path, type) {
|
|
23
|
+
if (!importRecords.has(path)) {
|
|
24
|
+
importRecords.set(path, new Set());
|
|
25
|
+
}
|
|
26
|
+
importRecords.get(path).add(type);
|
|
27
|
+
}
|
|
28
|
+
function ImportStatements(props) {
|
|
29
|
+
return memo(() => mapJoin(() => props.records, (path, types) => _$createComponent(ImportStatement, {
|
|
30
|
+
path: path,
|
|
31
|
+
types: types
|
|
32
|
+
})));
|
|
33
|
+
}
|
|
34
|
+
function ImportStatement(props) {
|
|
35
|
+
// when the `code` template tag is implemented, the lambda won't be needed.
|
|
36
|
+
return () => `import { ${[...props.types.values()].join(", ")} } from "${props.path}";`;
|
|
37
|
+
}
|
|
38
|
+
const tree = renderTree(_$createComponent(ImportStatements, {
|
|
39
|
+
records: importRecords
|
|
40
|
+
}));
|
|
41
|
+
// the tree is empty.
|
|
42
|
+
|
|
43
|
+
expect(printTree(tree)).toEqual("");
|
|
44
|
+
addImport("./foo.js", "hi");
|
|
45
|
+
printTree(tree);
|
|
46
|
+
expect(printTree(tree)).toEqual('import { hi } from "./foo.js";');
|
|
47
|
+
addImport("./foo.js", "bye");
|
|
48
|
+
expect(printTree(tree)).toEqual('import { hi, bye } from "./foo.js";');
|
|
49
|
+
addImport("node:assert", "strictEqual");
|
|
50
|
+
expect(printTree(tree)).toEqual(d`
|
|
51
|
+
import { hi, bye } from "./foo.js";
|
|
52
|
+
import { strictEqual } from "node:assert";
|
|
53
|
+
`);
|
|
54
|
+
});
|
|
55
|
+
it("works with memos of memos", () => {
|
|
56
|
+
const test = ref(1);
|
|
57
|
+
const tree = renderTree(memo(() => memo(() => test.value)));
|
|
58
|
+
expect(printTree(tree)).toEqual("1");
|
|
59
|
+
test.value = 2;
|
|
60
|
+
expect(printTree(tree)).toEqual("2");
|
|
61
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ref } from "@vue/reactivity";
|
|
2
|
+
import { expect, it } from "vitest";
|
|
3
|
+
import { memo, untrack } from "../../src/jsx-runtime.js";
|
|
4
|
+
it("ignores signals for dependency tracking", () => {
|
|
5
|
+
const signal = ref(0);
|
|
6
|
+
const m = memo(() => {
|
|
7
|
+
return untrack(() => signal.value);
|
|
8
|
+
});
|
|
9
|
+
expect(m()).toBe(0);
|
|
10
|
+
signal.value = 1;
|
|
11
|
+
expect(m()).toBe(0);
|
|
12
|
+
});
|
|
13
|
+
it("doesn't affect signal changes", () => {
|
|
14
|
+
const signal = ref(0);
|
|
15
|
+
const m = memo(() => {
|
|
16
|
+
return signal.value;
|
|
17
|
+
});
|
|
18
|
+
expect(m()).toBe(0);
|
|
19
|
+
untrack(() => {
|
|
20
|
+
signal.value = 1;
|
|
21
|
+
});
|
|
22
|
+
expect(m()).toBe(1);
|
|
23
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { expect, it } from "vitest";
|
|
2
|
+
import { refkey } from "../src/refkey.js";
|
|
3
|
+
it("is stable when called with same values", () => {
|
|
4
|
+
const obj = {};
|
|
5
|
+
const key1 = refkey(obj);
|
|
6
|
+
const key2 = refkey(obj);
|
|
7
|
+
expect(key1).toBe(key2);
|
|
8
|
+
});
|
|
9
|
+
it("supports primitive values", () => {
|
|
10
|
+
const key1 = refkey("hi");
|
|
11
|
+
const key2 = refkey("hi");
|
|
12
|
+
expect(key1).toBe(key2);
|
|
13
|
+
});
|
|
14
|
+
it("composes multiple keys", () => {
|
|
15
|
+
const obj1 = {};
|
|
16
|
+
const obj2 = {};
|
|
17
|
+
const key1 = refkey(obj1, obj2, "hi");
|
|
18
|
+
const key2 = refkey(obj1, obj2, "hi");
|
|
19
|
+
expect(key1).toBe(key2);
|
|
20
|
+
});
|
|
21
|
+
it("can be called with no args and returns a fresh key", () => {
|
|
22
|
+
const key1 = refkey();
|
|
23
|
+
const key2 = refkey();
|
|
24
|
+
expect(key1).not.toBe(key2);
|
|
25
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { createIntrinsic as _$createIntrinsic, createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import "../../testing/extend-expect.js";
|
|
4
|
+
describe("string nodes", () => {
|
|
5
|
+
it("renders string nodes with substitutions", () => {
|
|
6
|
+
const str = "hi";
|
|
7
|
+
expect(["a ", str, _$createIntrinsic("hbr", {}), str]).toRenderTo(`
|
|
8
|
+
a hi
|
|
9
|
+
hi
|
|
10
|
+
`);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
describe("component nodes", () => {
|
|
14
|
+
function Str() {
|
|
15
|
+
return "Str";
|
|
16
|
+
}
|
|
17
|
+
function Arr() {
|
|
18
|
+
return ["Item 1", "\n" + "Item 2"];
|
|
19
|
+
}
|
|
20
|
+
function Nested() {
|
|
21
|
+
return _$createComponent(Str, {});
|
|
22
|
+
}
|
|
23
|
+
it("renders basic component", () => {
|
|
24
|
+
expect(_$createComponent(Str, {})).toRenderTo("Str");
|
|
25
|
+
});
|
|
26
|
+
it("renders array components", () => {
|
|
27
|
+
expect(_$createComponent(Arr, {})).toRenderTo("Item 1\nItem 2");
|
|
28
|
+
});
|
|
29
|
+
it("renders nested components", () => {
|
|
30
|
+
expect(_$createComponent(Nested, {})).toRenderTo("Str");
|
|
31
|
+
});
|
|
32
|
+
it("renders components on same line", () => {
|
|
33
|
+
expect([_$createComponent(Str, {}), " ", _$createComponent(Str, {})]).toRenderTo("Str Str");
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
describe("memo nodes", () => {
|
|
37
|
+
function getStr() {
|
|
38
|
+
return "Str";
|
|
39
|
+
}
|
|
40
|
+
function Foo() {
|
|
41
|
+
return "Foo";
|
|
42
|
+
}
|
|
43
|
+
function getFoo() {
|
|
44
|
+
return _$createComponent(Foo, {});
|
|
45
|
+
}
|
|
46
|
+
function getArr() {
|
|
47
|
+
return [_$createComponent(Foo, {}), "\n", _$createComponent(Foo, {})];
|
|
48
|
+
}
|
|
49
|
+
it("renders basic memos", () => {
|
|
50
|
+
expect([_$memo(getStr)]).toRenderTo("Str");
|
|
51
|
+
});
|
|
52
|
+
it("renders component memos", () => {
|
|
53
|
+
expect([_$memo(getFoo)]).toRenderTo("Foo");
|
|
54
|
+
});
|
|
55
|
+
it("renders array memos", () => {
|
|
56
|
+
expect([_$memo(getArr)]).toRenderTo("Foo\nFoo");
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
describe("array nodes", () => {
|
|
60
|
+
it("renders basic arrays", () => {
|
|
61
|
+
expect([["hi", " ", "hi"]]).toRenderTo("hi hi");
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
it("renders text fragments", () => {
|
|
65
|
+
function Foo() {
|
|
66
|
+
return "bye";
|
|
67
|
+
}
|
|
68
|
+
expect(["hi", _$createIntrinsic("hbr", {}), _$createComponent(Foo, {})]).toRenderTo(`
|
|
69
|
+
hi
|
|
70
|
+
bye
|
|
71
|
+
`);
|
|
72
|
+
});
|
|
73
|
+
it("renders basic components", () => {
|
|
74
|
+
function Bar(props) {
|
|
75
|
+
return props.children;
|
|
76
|
+
}
|
|
77
|
+
function Foo() {
|
|
78
|
+
return _$createComponent(Bar, {
|
|
79
|
+
children: "hello"
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
expect(_$createComponent(Foo, {})).toRenderTo("hello");
|
|
83
|
+
});
|
|
84
|
+
it("renders booleans appropriately", () => {
|
|
85
|
+
function Foo() {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
expect(_$createComponent(Foo, {})).toRenderTo("");
|
|
89
|
+
});
|
|
90
|
+
it("keeps spaces between expressions", () => {
|
|
91
|
+
const str = "str";
|
|
92
|
+
function getStr() {
|
|
93
|
+
return "getStr";
|
|
94
|
+
}
|
|
95
|
+
expect(["a ", str, " ", str, " ", _$memo(getStr), " ", _$memo(getStr), " c"]).toRenderTo("a str str getStr getStr c");
|
|
96
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { code } from "@alloy-js/core";
|
|
3
|
+
import { expect, it } from "vitest";
|
|
4
|
+
import "../../testing/extend-expect.js";
|
|
5
|
+
it("renders simple strings", () => {
|
|
6
|
+
expect(code`foo`).toRenderTo("foo");
|
|
7
|
+
});
|
|
8
|
+
it("renders removes indents", () => {
|
|
9
|
+
expect(code`
|
|
10
|
+
foo
|
|
11
|
+
`).toRenderTo("foo");
|
|
12
|
+
});
|
|
13
|
+
it("renders allows substitutions of elements", () => {
|
|
14
|
+
function Foo() {
|
|
15
|
+
return "hi";
|
|
16
|
+
}
|
|
17
|
+
expect(code`
|
|
18
|
+
foo ${_$createComponent(Foo, {})} bar
|
|
19
|
+
`).toRenderTo("foo hi bar");
|
|
20
|
+
});
|
|
21
|
+
it("renders has auto-indentation", () => {
|
|
22
|
+
function Foo() {
|
|
23
|
+
return code`
|
|
24
|
+
hi
|
|
25
|
+
bye
|
|
26
|
+
`;
|
|
27
|
+
}
|
|
28
|
+
const template = code`
|
|
29
|
+
if (x === 1) {
|
|
30
|
+
${_$createComponent(Foo, {})}
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
expect(template).toRenderTo(`
|
|
34
|
+
if (x === 1) {
|
|
35
|
+
hi
|
|
36
|
+
bye
|
|
37
|
+
}
|
|
38
|
+
`);
|
|
39
|
+
});
|
|
40
|
+
it("handles blank lines", () => {
|
|
41
|
+
const template = code`
|
|
42
|
+
{
|
|
43
|
+
a
|
|
44
|
+
|
|
45
|
+
x
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
expect(template).toRenderTo(`
|
|
49
|
+
{
|
|
50
|
+
a
|
|
51
|
+
|
|
52
|
+
x
|
|
53
|
+
}
|
|
54
|
+
`);
|
|
55
|
+
});
|