Skip to content

Commit 29b3f87

Browse files
committed
add tests for event target
1 parent 20e5b33 commit 29b3f87

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/__test__/run-create-fields-test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,15 @@ export default function createFieldsTest(
3434
const fieldByProperty = (ipos_for_probing.myField as any).__original ?? ipos_for_probing.myField
3535
const fieldByFunction = (ipos_for_probing.get('myField') as any).__original ?? ipos_for_probing.get('myField')
3636

37-
// lodash equal to compare maps and sets
38-
expect(_.isEqualWith(fieldByProperty, value, customizer)).toEqual(true)
39-
expect(_.isEqualWith(fieldByFunction, value, customizer)).toEqual(true)
37+
// some objects cannot be "the same" (e.g. instances not holding data)
38+
if ([EventTarget].some(type => value instanceof type)) {
39+
expect(fieldByProperty.constructor === value.constructor).toBe(true)
40+
expect(fieldByFunction.constructor === value.constructor).toBe(true)
41+
} else {
42+
// lodash equal to compare maps and sets
43+
expect(_.isEqualWith(fieldByProperty, value, customizer)).toEqual(true)
44+
expect(_.isEqualWith(fieldByFunction, value, customizer)).toEqual(true)
45+
}
4046
}
4147
)
4248
})

src/__test__/test-data.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export const examples = {
3232
})),
3333
'set': new Set(['myItem', 42]),
3434
'function': (a: number, b: number) => a + b,
35-
'class': new TestClass('myClass')
35+
'class': new TestClass('myClass'),
36+
'eventTarget': new EventTarget(),
3637
}
3738

3839
// exemplary; don't iterate every possible method, just do one direct value assignment and one method

0 commit comments

Comments
 (0)