Skip to content

Commit 0123301

Browse files
test: add validation tests for null and undefined components (#73)
- Add tests for add() method with null and undefined values - Add tests for set() method with null and undefined values - Combine tests using forEach to reduce duplication and improve maintainability - Ensures both methods properly reject invalid component values
1 parent 9a7e569 commit 0123301

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

test/systemic.test.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,26 @@ describe('System', () => {
162162
);
163163
});
164164

165-
it('should reject attempts to add an undefined component', () => {
166-
assert.throws(
167-
() => {
168-
system.add('foo', undefined);
169-
},
170-
{ message: 'Component foo is null or undefined' }
171-
);
165+
it('should reject attempts to add null or undefined components', () => {
166+
[null, undefined].forEach((value) => {
167+
assert.throws(
168+
() => {
169+
system.add('foo', value);
170+
},
171+
{ message: 'Component foo is null or undefined' }
172+
);
173+
});
174+
});
175+
176+
it('should reject attempts to set null or undefined components', () => {
177+
[null, undefined].forEach((value) => {
178+
assert.throws(
179+
() => {
180+
system.set('foo', value);
181+
},
182+
{ message: 'Component foo is null or undefined' }
183+
);
184+
});
172185
});
173186

174187
it('should reject dependsOn called before adding components', () => {

0 commit comments

Comments
 (0)