Skip to content

Commit 78996e2

Browse files
committed
Add more test
1 parent 6ad5e5e commit 78996e2

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

tests/helpers.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,24 @@ export const unicodeSingle = [
2525
"",
2626
].join("\n");
2727

28+
export const withService = [
29+
"import { service } from '@ember/service';",
30+
"import Component from '@glimmer/component';",
31+
"",
32+
"export class ExampleComponent extends Component {",
33+
" @service('store') store;",
34+
" property = true;",
35+
"",
36+
" ask() {",
37+
" return 'hello world'",
38+
" }",
39+
"",
40+
" <template>",
41+
" <h2>My Component</h2>",
42+
" </template>",
43+
"}",
44+
].join("\n");
45+
2846
export const unicodeMulti = [
2947
"export const Run = <template>",
3048
" r̸̳͙̟̳̺̩̎̍̎̚͠ǘ̷̟̀͂̽̿̅̆̈́n̷̜̣̙̫̦̳͇̞̣̻͑̊̂́̿̈́̕͜͜͠ͅ",

tests/transformer.toStringWithTemplatePlaceholders.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { describe, it, expect } from "vitest";
33
import { Transformer } from "content-tag-utils";
44

55
import {
6+
withService,
67
implicitDefault,
78
inAClass,
89
multiTemplate,
@@ -111,6 +112,31 @@ it("multiWithClass", () => {
111112
expect(multiWithClass.length).toEqual(result.length);
112113
});
113114

115+
it("withService", () => {
116+
let t = new Transformer(withService);
117+
118+
let result = t.toString({ placeholders: true });
119+
120+
expect(result).toMatchInlineSnapshot(`
121+
"import { service } from '@ember/service';
122+
import Component from '@glimmer/component';
123+
124+
export class ExampleComponent extends Component {
125+
@service('store') store;
126+
property = true;
127+
128+
ask() {
129+
return 'hello world'
130+
}
131+
132+
[_TEMPLATE_(\`
133+
<h2>My Component</h2>
134+
\`)] = 0;
135+
}"
136+
`);
137+
expect(withService.length).toEqual(result.length);
138+
});
139+
114140
describe("with transforms", () => {
115141
it("noop", () => {
116142
let t = new Transformer(simpleTest);

0 commit comments

Comments
 (0)