diff options
Diffstat (limited to 'src/client/sync')
| -rw-r--r-- | src/client/sync/conflict.test.ts | 12 | ||||
| -rw-r--r-- | src/client/sync/conflict.ts | 4 | ||||
| -rw-r--r-- | src/client/sync/pull.test.ts | 16 | ||||
| -rw-r--r-- | src/client/sync/pull.ts | 8 | ||||
| -rw-r--r-- | src/client/sync/push.test.ts | 18 | ||||
| -rw-r--r-- | src/client/sync/push.ts | 4 | ||||
| -rw-r--r-- | src/client/sync/queue.test.ts | 18 |
7 files changed, 58 insertions, 22 deletions
diff --git a/src/client/sync/conflict.test.ts b/src/client/sync/conflict.test.ts index 6a10c4f..52362ff 100644 --- a/src/client/sync/conflict.test.ts +++ b/src/client/sync/conflict.test.ts @@ -271,6 +271,8 @@ describe("ConflictResolver", () => { const localCard = await localCardRepository.create({ deckId: deck.id, + noteId: "test-note-id", + isReversed: false, front: "Local Question", back: "Local Answer", }); @@ -278,6 +280,8 @@ describe("ConflictResolver", () => { const serverCard = { id: localCard.id, deckId: deck.id, + noteId: "test-note-id", + isReversed: false, front: "Server Question", back: "Server Answer", state: CardState.Review, @@ -316,6 +320,8 @@ describe("ConflictResolver", () => { const localCard = await localCardRepository.create({ deckId: deck.id, + noteId: "test-note-id", + isReversed: false, front: "Local Question", back: "Local Answer", }); @@ -323,6 +329,8 @@ describe("ConflictResolver", () => { const serverCard = { id: localCard.id, deckId: deck.id, + noteId: "test-note-id", + isReversed: false, front: "Server Question", back: "Server Answer", state: CardState.New, @@ -435,6 +443,8 @@ describe("ConflictResolver", () => { const card = await localCardRepository.create({ deckId: deck.id, + noteId: "test-note-id", + isReversed: false, front: "Local Question", back: "Local Answer", }); @@ -456,6 +466,8 @@ describe("ConflictResolver", () => { { id: card.id, deckId: deck.id, + noteId: "test-note-id", + isReversed: false, front: "Server Question", back: "Server Answer", state: CardState.New, diff --git a/src/client/sync/conflict.ts b/src/client/sync/conflict.ts index d9c3f55..2451920 100644 --- a/src/client/sync/conflict.ts +++ b/src/client/sync/conflict.ts @@ -91,8 +91,8 @@ function serverCardToLocal(card: ServerCard): LocalCard { return { id: card.id, deckId: card.deckId, - noteId: card.noteId ?? null, - isReversed: card.isReversed ?? null, + noteId: card.noteId, + isReversed: card.isReversed, front: card.front, back: card.back, state: card.state as LocalCard["state"], diff --git a/src/client/sync/pull.test.ts b/src/client/sync/pull.test.ts index 9ba678e..dd562a0 100644 --- a/src/client/sync/pull.test.ts +++ b/src/client/sync/pull.test.ts @@ -101,6 +101,8 @@ describe("pullResultToLocalData", () => { { id: "card-1", deckId: "deck-1", + noteId: "test-note-id", + isReversed: false, front: "Question", back: "Answer", state: CardState.Review, @@ -130,8 +132,8 @@ describe("pullResultToLocalData", () => { expect(result.cards[0]).toEqual({ id: "card-1", deckId: "deck-1", - noteId: null, - isReversed: null, + noteId: "test-note-id", + isReversed: false, front: "Question", back: "Answer", state: CardState.Review, @@ -156,6 +158,8 @@ describe("pullResultToLocalData", () => { { id: "card-1", deckId: "deck-1", + noteId: "test-note-id", + isReversed: false, front: "New Card", back: "Answer", state: CardState.New, @@ -568,8 +572,8 @@ describe("PullService", () => { { id: "server-card-1", deckId: deck.id, - noteId: null, - isReversed: null, + noteId: "test-note-id", + isReversed: false, front: "Server Question", back: "Server Answer", state: CardState.New, @@ -715,8 +719,8 @@ describe("PullService", () => { { id: "card-1", deckId: "deck-1", - noteId: null, - isReversed: null, + noteId: "test-note-id", + isReversed: false, front: "Q", back: "A", state: CardState.New, diff --git a/src/client/sync/pull.ts b/src/client/sync/pull.ts index 55c859c..8b55a9b 100644 --- a/src/client/sync/pull.ts +++ b/src/client/sync/pull.ts @@ -33,8 +33,8 @@ export interface ServerDeck { export interface ServerCard { id: string; deckId: string; - noteId?: string | null; - isReversed?: boolean | null; + noteId: string; + isReversed: boolean; front: string; back: string; state: number; @@ -172,8 +172,8 @@ function serverCardToLocal(card: ServerCard): LocalCard { return { id: card.id, deckId: card.deckId, - noteId: card.noteId ?? null, - isReversed: card.isReversed ?? null, + noteId: card.noteId, + isReversed: card.isReversed, front: card.front, back: card.back, state: card.state as CardStateType, diff --git a/src/client/sync/push.test.ts b/src/client/sync/push.test.ts index 9a42eff..16198c1 100644 --- a/src/client/sync/push.test.ts +++ b/src/client/sync/push.test.ts @@ -131,8 +131,8 @@ describe("pendingChangesToPushData", () => { { id: "card-1", deckId: "deck-1", - noteId: null, - isReversed: null, + noteId: "test-note-id", + isReversed: false, front: "Question", back: "Answer", state: CardState.Review, @@ -163,8 +163,8 @@ describe("pendingChangesToPushData", () => { expect(result.cards[0]).toEqual({ id: "card-1", deckId: "deck-1", - noteId: null, - isReversed: null, + noteId: "test-note-id", + isReversed: false, front: "Question", back: "Answer", state: CardState.Review, @@ -187,8 +187,8 @@ describe("pendingChangesToPushData", () => { { id: "card-1", deckId: "deck-1", - noteId: null, - isReversed: null, + noteId: "test-note-id", + isReversed: false, front: "New Card", back: "Answer", state: CardState.New, @@ -566,6 +566,8 @@ describe("PushService", () => { const card = await localCardRepository.create({ deckId: deck.id, + noteId: "test-note-id", + isReversed: false, front: "Question", back: "Answer", }); @@ -611,6 +613,8 @@ describe("PushService", () => { const card = await localCardRepository.create({ deckId: deck.id, + noteId: "test-note-id", + isReversed: false, front: "Q", back: "A", }); @@ -740,6 +744,8 @@ describe("PushService", () => { const card = await localCardRepository.create({ deckId: deck.id, + noteId: "test-note-id", + isReversed: false, front: "Q", back: "A", }); diff --git a/src/client/sync/push.ts b/src/client/sync/push.ts index f5c9275..b83136e 100644 --- a/src/client/sync/push.ts +++ b/src/client/sync/push.ts @@ -35,8 +35,8 @@ export interface SyncDeckData { export interface SyncCardData { id: string; deckId: string; - noteId: string | null; - isReversed: boolean | null; + noteId: string; + isReversed: boolean; front: string; back: string; state: number; diff --git a/src/client/sync/queue.test.ts b/src/client/sync/queue.test.ts index 2038e0d..e815282 100644 --- a/src/client/sync/queue.test.ts +++ b/src/client/sync/queue.test.ts @@ -85,6 +85,8 @@ describe("SyncQueue", () => { }); await localCardRepository.create({ deckId: deck.id, + noteId: "test-note-id", + isReversed: false, front: "Question", back: "Answer", }); @@ -103,6 +105,8 @@ describe("SyncQueue", () => { }); const card = await localCardRepository.create({ deckId: deck.id, + noteId: "test-note-id", + isReversed: false, front: "Question", back: "Answer", }); @@ -145,11 +149,15 @@ describe("SyncQueue", () => { }); await localCardRepository.create({ deckId: deck.id, + noteId: "test-note-id-1", + isReversed: false, front: "Q1", back: "A1", }); await localCardRepository.create({ deckId: deck.id, + noteId: "test-note-id-2", + isReversed: false, front: "Q2", back: "A2", }); @@ -323,6 +331,8 @@ describe("SyncQueue", () => { }); const card = await localCardRepository.create({ deckId: deck.id, + noteId: "test-note-id", + isReversed: false, front: "Q", back: "A", }); @@ -351,6 +361,8 @@ describe("SyncQueue", () => { }); const card = await localCardRepository.create({ deckId: deck.id, + noteId: "test-note-id", + isReversed: false, front: "Q", back: "A", }); @@ -440,8 +452,8 @@ describe("SyncQueue", () => { const serverCard = { id: "server-card-1", deckId: deck.id, - noteId: null, - isReversed: null, + noteId: "test-note-id", + isReversed: false, front: "Server Question", back: "Server Answer", state: CardState.New, @@ -484,6 +496,8 @@ describe("SyncQueue", () => { }); const card = await localCardRepository.create({ deckId: deck.id, + noteId: "test-note-id", + isReversed: false, front: "Q", back: "A", }); |
