Skip to content

Commit c36590a

Browse files
committed
Test more unknown expected type, but maybe some bug?
1 parent 55e9202 commit c36590a

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

test/matchers/element/toHaveElementProperty.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,44 @@ describe(toHaveElementProperty, () => {
3838
})
3939
})
4040

41+
test('success with when property value is number', async () => {
42+
vi.mocked(el.getProperty).mockResolvedValue(5)
43+
44+
const result = await thisContext.toHaveElementProperty(el, 'property', 5)
45+
46+
expect(result.pass).toBe(true)
47+
})
48+
49+
// TODO With unknonwn as expect should array be be supported ? If so this is a bug!!!
50+
test('success with when property value is an array, bug?', async () => {
51+
vi.mocked(el.getProperty).mockResolvedValue([5])
52+
53+
const result = await thisContext.toHaveElementProperty(el, 'property', [5])
54+
55+
expect(result.pass).toBe(false)
56+
expect(result.message()).toEqual(`\
57+
Expect $(\`sel\`) to have property property
58+
59+
Expected: [5]
60+
Received: "Expected value cannot be an array"`
61+
)
62+
})
63+
64+
// TODO With unknonwn as expect should array be be supported ? If so this is a bug!!!
65+
test('success with when property value an object, bug?', async () => {
66+
vi.mocked(el.getProperty).mockResolvedValue( { foo: 'bar' } )
67+
68+
const result = await thisContext.toHaveElementProperty(el, 'property', { foo: 'bar' } )
69+
70+
expect(result.pass).toBe(false)
71+
expect(result.message()).toEqual(`\
72+
Expect $(\`sel\`) to have property property
73+
74+
Expected: {"foo": "bar"}
75+
Received: {"foo": "bar"}`
76+
)
77+
})
78+
4179
test('assymeric match', async () => {
4280
const result = await thisContext.toHaveElementProperty(el, 'property', expect.stringContaining('phone'))
4381
expect(result.pass).toBe(true)

0 commit comments

Comments
 (0)