Skip to content

Commit abae74a

Browse files
committed
fix ember 6 tests
1 parent bd18685 commit abae74a

File tree

2 files changed

+177
-137
lines changed

2 files changed

+177
-137
lines changed

tests/ember_debug/profile-manager-test.js

Lines changed: 122 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import setupEmberDebugTest from '../helpers/setup-ember-debug-test';
1212
import { run } from '@ember/runloop';
1313
import Ember from 'ember-debug/utils/ember';
1414
import { compareVersion } from 'ember-debug/utils/version';
15+
import { setComponentTemplate } from '@ember/component';
1516

1617
const { VERSION } = Ember;
1718

@@ -28,119 +29,123 @@ const getRounded = (value) => {
2829
}
2930
return Math.floor(data);
3031
};
31-
class OneRootGlimmer extends GlimmerComponent {
32-
classNames = 'simple-component';
33-
}
3432

35-
const mockedComponents = {
36-
text: {
37-
component: EmberComponent.extend({
38-
tagName: '',
39-
}),
40-
template: hbs('text only', {
41-
moduleName: 'my-app/templates/components/text.hbs',
42-
}),
43-
},
44-
'text-glimmer': {
45-
component: GlimmerComponent,
46-
template: hbs('text only', {
47-
moduleName: 'my-app/templates/components/text-glimmer.hbs',
48-
}),
49-
},
50-
comment: {
51-
component: EmberComponent.extend({
52-
tagName: '',
53-
}),
54-
template: hbs('<!-- comment -->', {
55-
moduleName: 'my-app/templates/components/comment.hbs',
56-
}),
57-
},
58-
'comment-glimmer': {
59-
component: GlimmerComponent,
60-
template: hbs('<!-- comment -->', {
61-
moduleName: 'my-app/templates/components/comment-glimmer.hbs',
62-
}),
63-
},
64-
'one-root': {
65-
component: EmberComponent.extend({
66-
tagName: '',
67-
}),
68-
template: hbs('<div class="simple-component">one root</div>', {
69-
moduleName: 'my-app/templates/components/one-root.hbs',
70-
}),
71-
},
72-
'one-root-glimmer': {
73-
component: OneRootGlimmer,
74-
template: hbs('<div class={{this.classNames}}>one root</div>', {
75-
moduleName: 'my-app/templates/components/one-root-glimmer.hbs',
76-
}),
77-
},
78-
'two-root': {
79-
component: EmberComponent.extend({
80-
tagName: '',
81-
}),
82-
template: hbs(
83-
'<div class="simple-component">one</div><div class="another-component">two</div>',
84-
{ moduleName: 'my-app/templates/components/two-root.hbs' },
85-
),
86-
},
87-
'two-root-glimmer': {
88-
component: GlimmerComponent,
89-
template: hbs(
90-
'<div class="simple-component">one</div><div class="another-component">two</div>',
91-
{ moduleName: 'my-app/templates/components/two-root-glimmer.hbs' },
92-
),
93-
},
94-
'root-comment-root': {
95-
component: EmberComponent.extend({
96-
tagName: '',
97-
}),
98-
template: hbs(
99-
'<div class="simple-component">one</div><!-- comment --><div class="another-component">two</div>',
100-
{ moduleName: 'my-app/templates/components/root-comment-root.hbs' },
101-
),
102-
},
103-
'root-comment-root-glimmer': {
104-
component: GlimmerComponent,
105-
template: hbs(
106-
'<div class="simple-component">one</div><!-- comment --><div class="another-component">two</div>',
107-
{
108-
moduleName: 'my-app/templates/components/root-comment-root-glimmer.hbs',
109-
},
110-
),
111-
},
112-
'comment-root-comment': {
113-
component: EmberComponent.extend({
114-
tagName: '',
115-
}),
116-
template: hbs(
117-
'<!-- comment 1 --><div class="simple-component">one</div><!-- comment 2 -->',
118-
{ moduleName: 'my-app/templates/components/comment-root-comment.hbs' },
119-
),
120-
},
121-
'comment-root-comment-glimmer': {
122-
component: GlimmerComponent,
123-
template: hbs(
124-
'<!-- comment 1 --><div class="simple-component">one</div><!-- comment 2 -->',
125-
{ moduleName: 'my-app/templates/components/comment-root-comment.hbs' },
126-
),
127-
},
128-
'div-tag': {
129-
component: EmberComponent.extend({
130-
classNames: ['simple-component'],
131-
}),
132-
template: hbs('text in div', {
133-
moduleName: 'my-app/templates/components/div-tag.hbs',
134-
}),
135-
},
136-
'div-roots': {
137-
component: EmberComponent.extend({
138-
classNames: ['simple-component'],
139-
}),
140-
template: hbs('<div>one</div><div>two</div>', {
141-
moduleName: 'my-app/templates/components/div-roots.hbs',
142-
}),
143-
},
33+
const mockedComponents = () => {
34+
class OneRootGlimmer extends GlimmerComponent {
35+
classNames = 'simple-component';
36+
}
37+
38+
return {
39+
text: {
40+
component: EmberComponent.extend({
41+
tagName: '',
42+
}),
43+
template: hbs('text only', {
44+
moduleName: 'my-app/templates/components/text.hbs',
45+
}),
46+
},
47+
'text-glimmer': {
48+
component: class extends GlimmerComponent {},
49+
template: hbs('text only', {
50+
moduleName: 'my-app/templates/components/text-glimmer.hbs',
51+
}),
52+
},
53+
comment: {
54+
component: EmberComponent.extend({
55+
tagName: '',
56+
}),
57+
template: hbs('<!-- comment -->', {
58+
moduleName: 'my-app/templates/components/comment.hbs',
59+
}),
60+
},
61+
'comment-glimmer': {
62+
component: class extends GlimmerComponent {},
63+
template: hbs('<!-- comment -->', {
64+
moduleName: 'my-app/templates/components/comment-glimmer.hbs',
65+
}),
66+
},
67+
'one-root': {
68+
component: EmberComponent.extend({
69+
tagName: '',
70+
}),
71+
template: hbs('<div class="simple-component">one root</div>', {
72+
moduleName: 'my-app/templates/components/one-root.hbs',
73+
}),
74+
},
75+
'one-root-glimmer': {
76+
component: OneRootGlimmer,
77+
template: hbs('<div class={{this.classNames}}>one root</div>', {
78+
moduleName: 'my-app/templates/components/one-root-glimmer.hbs',
79+
}),
80+
},
81+
'two-root': {
82+
component: EmberComponent.extend({
83+
tagName: '',
84+
}),
85+
template: hbs(
86+
'<div class="simple-component">one</div><div class="another-component">two</div>',
87+
{ moduleName: 'my-app/templates/components/two-root.hbs' },
88+
),
89+
},
90+
'two-root-glimmer': {
91+
component: class extends GlimmerComponent {},
92+
template: hbs(
93+
'<div class="simple-component">one</div><div class="another-component">two</div>',
94+
{ moduleName: 'my-app/templates/components/two-root-glimmer.hbs' },
95+
),
96+
},
97+
'root-comment-root': {
98+
component: EmberComponent.extend({
99+
tagName: '',
100+
}),
101+
template: hbs(
102+
'<div class="simple-component">one</div><!-- comment --><div class="another-component">two</div>',
103+
{ moduleName: 'my-app/templates/components/root-comment-root.hbs' },
104+
),
105+
},
106+
'root-comment-root-glimmer': {
107+
component: class extends GlimmerComponent {},
108+
template: hbs(
109+
'<div class="simple-component">one</div><!-- comment --><div class="another-component">two</div>',
110+
{
111+
moduleName:
112+
'my-app/templates/components/root-comment-root-glimmer.hbs',
113+
},
114+
),
115+
},
116+
'comment-root-comment': {
117+
component: EmberComponent.extend({
118+
tagName: '',
119+
}),
120+
template: hbs(
121+
'<!-- comment 1 --><div class="simple-component">one</div><!-- comment 2 -->',
122+
{ moduleName: 'my-app/templates/components/comment-root-comment.hbs' },
123+
),
124+
},
125+
'comment-root-comment-glimmer': {
126+
component: class extends GlimmerComponent {},
127+
template: hbs(
128+
'<!-- comment 1 --><div class="simple-component">one</div><!-- comment 2 -->',
129+
{ moduleName: 'my-app/templates/components/comment-root-comment.hbs' },
130+
),
131+
},
132+
'div-tag': {
133+
component: EmberComponent.extend({
134+
classNames: ['simple-component'],
135+
}),
136+
template: hbs('text in div', {
137+
moduleName: 'my-app/templates/components/div-tag.hbs',
138+
}),
139+
},
140+
'div-roots': {
141+
component: EmberComponent.extend({
142+
classNames: ['simple-component'],
143+
}),
144+
template: hbs('<div>one</div><div>two</div>', {
145+
moduleName: 'my-app/templates/components/div-roots.hbs',
146+
}),
147+
},
148+
};
144149
};
145150

146151
const mockedRoutes = {
@@ -264,6 +269,10 @@ const constructComponents = (owner, componentsMap) => {
264269
`template:components/${componentKey}`,
265270
componentsMap[componentKey].template,
266271
);
272+
setComponentTemplate(
273+
componentsMap[componentKey].template,
274+
componentsMap[componentKey].component,
275+
);
267276
}
268277
}
269278
};
@@ -398,7 +407,7 @@ module('Ember Debug - profile manager component highlight', function (hooks) {
398407
hooks.beforeEach(async function () {
399408
EmberDebug.IGNORE_DEPRECATIONS = true;
400409
constructBase(this.owner);
401-
constructComponents(this.owner, mockedComponents);
410+
constructComponents(this.owner, mockedComponents());
402411
});
403412

404413
hooks.afterEach(function (assert) {

0 commit comments

Comments
 (0)