Skip to content

Commit

Permalink
includes gts in typescript test
Browse files Browse the repository at this point in the history
add babel typescript transform
  • Loading branch information
patricklx committed Sep 17, 2024
1 parent f7656a3 commit 5f70b4b
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions tests/scenarios/typescript-app-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,31 @@ let typescriptApp = tsAppScenarios.map('typescript-app', project => {
merge(project.files, {
app: {
components: {
'test-gts.gts': `
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { on } from '@ember/modifier';
interface Signature {
Element: HTMLDivElement;
Blocks: {
default: [number]
}
}
export default class Incrementer extends Component<Signature> {
@tracked count = 0;
@action increment() { this.count++ }
<template>
<div ...attributes>
<button {{on 'click' this.increment}}>increment</button>
{{yield this.count}}
</div>
</template>
}
`,
'incrementer.ts': `
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
Expand Down Expand Up @@ -36,6 +61,29 @@ let typescriptApp = tsAppScenarios.map('typescript-app', project => {
},
tests: {
rendering: {
'gts-test.gts': `
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, click } from '@ember/test-helpers';
import TestGts from '/app/components/test-gts';
module('Rendering', function (hooks) {
setupRenderingTest(hooks);
test('increments', async function (assert) {
await render(<template>
<TestGts as |count|>
<out>{{count}}</out>
</TestGts>
</template>);
assert.dom('out').hasText('0');
await click('button');
assert.dom('out').hasText('1');
});
});
`,
'incrementer-test.ts': `
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
Expand Down
1 change: 1 addition & 0 deletions tests/ts-app-template/babel.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { babelCompatSupport, templateCompatSupport } = require('@embroider/compat

module.exports = {
plugins: [
['@babel/plugin-transform-typescript'],
[
'babel-plugin-ember-template-compilation',
{
Expand Down
1 change: 1 addition & 0 deletions tests/ts-app-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},
"devDependencies": {
"@babel/core": "^7.22.20",
"@babel/plugin-transform-typescript": "^7.21.3",
"@babel/eslint-parser": "^7.21.3",
"@babel/plugin-proposal-decorators": "^7.21.0",
"@ember/optional-features": "^2.0.0",
Expand Down

0 comments on commit 5f70b4b

Please sign in to comment.