Skip to content
This repository was archived by the owner on Aug 2, 2024. It is now read-only.

Commit 83a1e79

Browse files
committed
Add failing test
1 parent 479e933 commit 83a1e79

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

tests/integration/helpers/is-component-definition-test.js

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,49 @@ import { module, test } from 'qunit';
33
import { setupRenderingTest } from 'ember-qunit';
44
import { render } from '@ember/test-helpers';
55

6+
function createMockGlimmerComponentDefinition() {
7+
return {
8+
[Symbol('INNER')]: {
9+
name: 'mock-component',
10+
ComponentClass: {},
11+
template: {},
12+
manager: {},
13+
state: {},
14+
},
15+
};
16+
}
17+
618
module('Integration | Helper | is-component-definition', function (hooks) {
719
setupRenderingTest(hooks);
820

9-
// Replace this with your real tests.
10-
test('it renders', async function (assert) {
11-
this.set('inputValue', '1234');
12-
13-
await render(hbs`{{if (is-component-definition inputValue) "yes" "no"}}`);
21+
test('it detects component definitions correctly', async function (assert) {
22+
await render(hbs`{{if (is-component-definition "1234") "yes" "no"}}`);
1423
assert
1524
.dom(this.element)
16-
.hasText('no', "returns false when it's not a component definition");
25+
.hasText(
26+
'no',
27+
'returns false when passed something other than a component definition'
28+
);
1729

1830
await render(
1931
hbs`{{if (is-component-definition (component "polaris-heading" text="Text")) "yes" "no"}}`
2032
);
2133
assert
2234
.dom(this.element)
23-
.hasText('yes', "returns true when it's a component definition");
35+
.hasText('yes', 'returns true when passed a component definition');
36+
37+
this.set(
38+
'glimmerComponentDefinition',
39+
createMockGlimmerComponentDefinition()
40+
);
41+
await render(
42+
hbs`{{if (is-component-definition this.glimmerComponentDefinition) "yes" "no"}}`
43+
);
44+
assert
45+
.dom(this.element)
46+
.hasText(
47+
'yes',
48+
'returns true when passed a Glimmer component definition'
49+
);
2450
});
2551
});

0 commit comments

Comments
 (0)