22 lines
940 B
TypeScript
22 lines
940 B
TypeScript
import { readFile } from 'node:fs/promises'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
describe('sync contract', () => {
|
|
it('does not treat browser connectivity state as proof that the API is reachable', async () => {
|
|
const source = await readFile(fileURLToPath(new URL('./sync.ts', import.meta.url)), 'utf8')
|
|
|
|
expect(source).not.toContain('navigator.onLine')
|
|
expect(source).toContain("window.addEventListener('online'")
|
|
expect(source).toContain("document.addEventListener('visibilitychange'")
|
|
})
|
|
|
|
it('reacts immediately to local capture events and coalesces concurrent sync requests', async () => {
|
|
const source = await readFile(fileURLToPath(new URL('./sync.ts', import.meta.url)), 'utf8')
|
|
|
|
expect(source).toContain('FIELDLENS_SYNC_REQUEST_EVENT')
|
|
expect(source).toContain('syncRequested = true')
|
|
expect(source).toContain('while (syncRequested)')
|
|
})
|
|
})
|