Skip to content

Commit 1ce86fa

Browse files
committed
don't depend on .gts type removal
The .gts type removal is buggy at the moment, and causes this PR to be blocked. We now add .gjs blueprints and strip the version we don't need, which bypasses the detyping problems.
1 parent 90f27da commit 1ce86fa

File tree

4 files changed

+53
-6
lines changed

4 files changed

+53
-6
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<% if (testType === 'integration') { %>import { module, test } from 'qunit';
2+
import { setupRenderingTest } from '<%= modulePrefix %>/tests/helpers';
3+
import { render } from '@ember/test-helpers';
4+
import <%= componentName %> from '<%= modulePrefix %>/components/<%= componentPathName %>';
5+
6+
module('<%= friendlyTestDescription %>', function (hooks) {
7+
setupRenderingTest(hooks);
8+
9+
test('it renders', async function (assert) {
10+
// Updating values is achieved using autotracking, just like in app code. For example:
11+
// class State { @tracked myProperty = 0; }; const state = new State();
12+
// and update using state.myProperty = 1; await rerender();
13+
// Handle any actions with function myAction(val) { ... };
14+
15+
await render(<template><%= selfCloseComponent(componentName) %></template>);
16+
17+
assert.dom().hasText('');
18+
19+
// Template block usage:
20+
await render(<template>
21+
<%= openComponent(componentName) %>
22+
template block text
23+
<%= closeComponent(componentName) %>
24+
</template>);
25+
26+
assert.dom().hasText('template block text');
27+
});
28+
});<% } else if (testType === 'unit') { %>import { module, test } from 'qunit';
29+
import { setupTest } from '<%= modulePrefix %>/tests/helpers';
30+
31+
module('<%= friendlyTestDescription %>', function (hooks) {
32+
setupTest(hooks);
33+
34+
test('it exists', function (assert) {
35+
let component = this.owner.factoryFor('component:<%= componentPathName %>').create();
36+
assert.ok(component);
37+
});
38+
}); <% } %>

blueprints/component-test/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ module.exports = {
7676
let files = this._super.files.apply(this, arguments);
7777

7878
if (this.options.componentAuthoringFormat === 'strict') {
79-
files = files.filter((file) => !(file.endsWith('.js') || file.endsWith('.ts')));
80-
}
81-
if (this.options.componentAuthoringFormat === 'loose') {
79+
const strictFilesToRemove = this.options.isTypeScriptProject || this.options.typescript ? '.gjs' : '.gts';
80+
files = files.filter((file) => !(file.endsWith('.js') || file.endsWith('.ts') || strictFilesToRemove));
81+
} else {
8282
files = files.filter((file) => !(file.endsWith('.gjs') || file.endsWith('.gts')));
8383
}
8484

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<% if (componentClass === '@glimmer/component') {%>import Component from '@glimmer/component';
2+
3+
export default class <%= classifiedModuleName %> extends Component {
4+
<template>
5+
{{yield}}
6+
</template>
7+
}<%} else {%><template>
8+
{{yield}}
9+
</template><%}%>

blueprints/component/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ module.exports = {
162162
});
163163
}
164164
if (this.options.componentAuthoringFormat === 'strict') {
165+
const strictFilesToRemove = this.options.isTypeScriptProject || this.options.typescript ? '.gjs' : '.gts';
165166
files = files.filter(
166-
(file) => !(file.endsWith('.js') || file.endsWith('.ts') || file.endsWith('.hbs'))
167+
(file) => !(file.endsWith('.js') || file.endsWith('.ts') || file.endsWith('.hbs') || file.endsWith(strictFilesToRemove))
167168
);
168-
}
169-
if (this.options.componentAuthoringFormat === 'loose') {
169+
} else {
170170
files = files.filter((file) => !(file.endsWith('.gjs') || file.endsWith('.gts')));
171171
}
172172

0 commit comments

Comments
 (0)