Skip to content

Commit 0cf126c

Browse files
committed
add test assertion
1 parent b281732 commit 0cf126c

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/lib/seam/components/DeviceTable/DeviceTable.test.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,34 @@ import { render, screen } from 'fixtures/react.js'
55

66
import { DeviceTable } from './DeviceTable.js'
77

8-
test<ApiTestContext>('DeviceTable', async (ctx) => {
8+
test<ApiTestContext>('DeviceTable renders devices', async (ctx) => {
99
render(<DeviceTable />, ctx)
1010
await screen.findByText('Fake August Lock 1')
1111
})
12+
13+
test<ApiTestContext>('DeviceTable renders generic lock device', async (ctx) => {
14+
const existingDevice = ctx.database.devices[0]
15+
16+
ctx.database.addDevice({
17+
device_id: 'august_generic_lock_device',
18+
device_type: 'august_lock',
19+
name: 'Generic August Device',
20+
display_name: 'Generic August Device',
21+
connected_account_id: existingDevice?.connected_account_id,
22+
can_remotely_unlock: false,
23+
can_remotely_lock: false,
24+
can_program_online_access_codes: true,
25+
properties: {
26+
online: false,
27+
manufacturer: 'august',
28+
name: 'Generic August Device',
29+
},
30+
workspace_id: existingDevice?.workspace_id ?? '',
31+
errors: [],
32+
warnings: [],
33+
custom_metadata: {},
34+
})
35+
36+
render(<DeviceTable />, ctx)
37+
await screen.findByText('Generic August Device')
38+
})

test/fixtures/api.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ import {
22
createFake as createFakeDevicedb,
33
type Fake as FakeDevicedb,
44
} from '@seamapi/fake-devicedb'
5-
import { createFake, type Fake, type Seed } from '@seamapi/fake-seam-connect'
5+
import {
6+
createFake,
7+
type Database,
8+
type Fake,
9+
type Seed,
10+
} from '@seamapi/fake-seam-connect'
611
import { beforeEach } from 'vitest'
712

813
export interface ApiTestContext {
914
endpoint: string
1015
seed: Seed
16+
database: Database
1117
}
1218

1319
beforeEach<ApiTestContext>(async (ctx) => {
@@ -22,6 +28,7 @@ beforeEach<ApiTestContext>(async (ctx) => {
2228

2329
ctx.endpoint = endpoint
2430
ctx.seed = seed
31+
ctx.database = fake.database
2532

2633
return () => {
2734
fake.server?.close()

0 commit comments

Comments
 (0)