Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tests/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ export const unicodeSingle = [
"",
].join("\n");

export const withService = [
"import { service } from '@ember/service';",
"import Component from '@glimmer/component';",
"",
"export class ExampleComponent extends Component {",
" @service('store') store;",
" property = true;",
"",
" ask() {",
" return 'hello world'",
" }",
"",
" <template>",
" <h2>My Component</h2>",
" </template>",
"}",
].join("\n");

export const unicodeMulti = [
"export const Run = <template>",
" r̸̳͙̟̳̺̩̎̍̎̚͠ǘ̷̟̀͂̽̿̅̆̈́n̷̜̣̙̫̦̳͇̞̣̻͑̊̂́̿̈́̕͜͜͠ͅ",
Expand Down
26 changes: 26 additions & 0 deletions tests/transformer.toStringWithTemplatePlaceholders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { describe, it, expect } from "vitest";
import { Transformer } from "content-tag-utils";

import {
withService,
implicitDefault,
inAClass,
multiTemplate,
Expand Down Expand Up @@ -111,6 +112,31 @@ it("multiWithClass", () => {
expect(multiWithClass.length).toEqual(result.length);
});

it("withService", () => {
let t = new Transformer(withService);

let result = t.toString({ placeholders: true });

expect(result).toMatchInlineSnapshot(`
"import { service } from '@ember/service';
import Component from '@glimmer/component';

export class ExampleComponent extends Component {
@service('store') store;
property = true;

ask() {
return 'hello world'
}

[_TEMPLATE_(\`
<h2>My Component</h2>
\`)] = 0;
}"
`);
expect(withService.length).toEqual(result.length);
});

describe("with transforms", () => {
it("noop", () => {
let t = new Transformer(simpleTest);
Expand Down