Skip to content

Commit

Permalink
add test assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
mikewuu committed Jan 15, 2025
1 parent b281732 commit 0cf126c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
29 changes: 28 additions & 1 deletion src/lib/seam/components/DeviceTable/DeviceTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,34 @@ import { render, screen } from 'fixtures/react.js'

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

test<ApiTestContext>('DeviceTable', async (ctx) => {
test<ApiTestContext>('DeviceTable renders devices', async (ctx) => {
render(<DeviceTable />, ctx)
await screen.findByText('Fake August Lock 1')
})

test<ApiTestContext>('DeviceTable renders generic lock device', async (ctx) => {
const existingDevice = ctx.database.devices[0]

ctx.database.addDevice({
device_id: 'august_generic_lock_device',
device_type: 'august_lock',
name: 'Generic August Device',
display_name: 'Generic August Device',
connected_account_id: existingDevice?.connected_account_id,
can_remotely_unlock: false,
can_remotely_lock: false,
can_program_online_access_codes: true,
properties: {
online: false,
manufacturer: 'august',
name: 'Generic August Device',
},
workspace_id: existingDevice?.workspace_id ?? '',
errors: [],
warnings: [],
custom_metadata: {},
})

render(<DeviceTable />, ctx)
await screen.findByText('Generic August Device')
})
9 changes: 8 additions & 1 deletion test/fixtures/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ import {
createFake as createFakeDevicedb,
type Fake as FakeDevicedb,
} from '@seamapi/fake-devicedb'
import { createFake, type Fake, type Seed } from '@seamapi/fake-seam-connect'
import {
createFake,
type Database,
type Fake,
type Seed,
} from '@seamapi/fake-seam-connect'
import { beforeEach } from 'vitest'

export interface ApiTestContext {
endpoint: string
seed: Seed
database: Database
}

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

ctx.endpoint = endpoint
ctx.seed = seed
ctx.database = fake.database

return () => {
fake.server?.close()
Expand Down

0 comments on commit 0cf126c

Please sign in to comment.