Skip to content

Commit 730bd9b

Browse files
committed
Added a test that shows that only functions with 3 args are renderers
1 parent de310f4 commit 730bd9b

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

node_package/tests/ComponentRegistry.test.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,19 @@ test('ComponentRegistry registers and retrieves multiple components', (assert) =
7777
{ name: 'C6', component: C6, generatorFunction: true, isRenderer: false });
7878
});
7979

80+
test('ComponentRegistry only detects a renderer function if it has three arguments', (assert) => {
81+
assert.plan(2);
82+
const C7 = (a1, a2) => null;
83+
const C8 = (a1) => null;
84+
ComponentRegistry.register({ C7 });
85+
ComponentRegistry.register({ C8 });
86+
const components = ComponentRegistry.components();
87+
assert.deepEqual(components.get('C7'),
88+
{ name: 'C7', component: C7, generatorFunction: true, isRenderer: false });
89+
assert.deepEqual(components.get('C8'),
90+
{ name: 'C8', component: C8, generatorFunction: true, isRenderer: false });
91+
});
92+
8093
test('ComponentRegistry throws error for retrieving unregistered component', (assert) => {
8194
assert.plan(1);
8295
assert.throws(() => ComponentRegistry.get('foobar'),
@@ -87,9 +100,9 @@ test('ComponentRegistry throws error for retrieving unregistered component', (as
87100

88101
test('ComponentRegistry throws error for setting null component', (assert) => {
89102
assert.plan(1);
90-
const C7 = null;
91-
assert.throws(() => ComponentRegistry.register({ C7 }),
92-
/Called register with null component named C7/,
103+
const C9 = null;
104+
assert.throws(() => ComponentRegistry.register({ C9 }),
105+
/Called register with null component named C9/,
93106
'Expected an exception for calling ComponentRegistry.set with a null component.'
94107
);
95108
});

0 commit comments

Comments
 (0)