Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/services/SyncService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ class SyncService {
this.bus.emit('stateChange', { dirty: true })
}
if (!this.hasActiveConnection()) {
this.#sending = false
return
}
const sendable = this.#outbox.getDataToSend()
Expand Down
11 changes: 11 additions & 0 deletions src/tests/services/SyncService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ const initialData = {
const openResult = { connection, data: initialData }

describe('Sync service', () => {
it('resets #sending when there is no active connection', async () => {
const { connection, openConnection } = provideConnection(
{ fileId: 123, relativePath: './' },
vi.fn(),
vi.fn(),
)
const service = new SyncService({ connection, openConnection })
await service.sendStepsNow()
await expect(service.sendStepsNow()).resolves.toBeUndefined()
})

it('opens a connection', async () => {
const getBaseVersionEtag = vi.fn()
const setBaseVersionEtag = vi.fn()
Expand Down