1- import { describe , it , expect } from "vitest" ;
1+ import { mergeAndDedup } from '~/helpers/apollo-cache/merge' ;
2+ import { describe , expect , it } from 'vitest' ;
23
3- import { mergeAndDedup , type ApolloCacheItem } from "./ merge" ;
4+ import type { ApolloCacheItem } from '~/helpers/apollo-cache/ merge' ;
45
5- describe ( " mergeAndDedup" , ( ) => {
6+ describe ( ' mergeAndDedup' , ( ) => {
67 const createRef = ( id : unknown ) => ( { __ref : `Post:${ id } ` } ) ;
78 const getRef = ( item : ApolloCacheItem ) => item . __ref ;
89
9- describe ( " basic functionality" , ( ) => {
10- it ( " should concatenate when there are no duplicates" , ( ) => {
10+ describe ( ' basic functionality' , ( ) => {
11+ it ( ' should concatenate when there are no duplicates' , ( ) => {
1112 const existing = [ createRef ( 1 ) , createRef ( 2 ) , createRef ( 3 ) ] ;
1213 const incoming = [ createRef ( 4 ) , createRef ( 5 ) ] ;
1314
@@ -24,7 +25,7 @@ describe("mergeAndDedup", () => {
2425 ] ) ;
2526 } ) ;
2627
27- it ( " should merge without duplicates when offset is 0" , ( ) => {
28+ it ( ' should merge without duplicates when offset is 0' , ( ) => {
2829 const existing = [ createRef ( 1 ) , createRef ( 2 ) , createRef ( 3 ) ] ;
2930
3031 const incoming = [
@@ -40,7 +41,7 @@ describe("mergeAndDedup", () => {
4041 ] ) ;
4142 } ) ;
4243
43- it ( " should merge without duplicates when offset > 0" , ( ) => {
44+ it ( ' should merge without duplicates when offset > 0' , ( ) => {
4445 const existing = [ createRef ( 1 ) , createRef ( 2 ) , createRef ( 3 ) , createRef ( 5 ) ] ;
4546
4647 const incoming = [
@@ -58,7 +59,7 @@ describe("mergeAndDedup", () => {
5859 ] ) ;
5960 } ) ;
6061
61- it ( " should handle duplicates > range of replacement" , ( ) => {
62+ it ( ' should handle duplicates > range of replacement' , ( ) => {
6263 const existing = [ createRef ( 1 ) , createRef ( 2 ) , createRef ( 3 ) , createRef ( 4 ) , createRef ( 2 ) ] ;
6364
6465 const incoming = [
@@ -75,7 +76,7 @@ describe("mergeAndDedup", () => {
7576 ] ) ;
7677 } ) ;
7778
78- it ( " should handle duplicate < range of replacement" , ( ) => {
79+ it ( ' should handle duplicate < range of replacement' , ( ) => {
7980 const existing = [ createRef ( 4 ) , createRef ( 2 ) , createRef ( 3 ) , createRef ( 1 ) ] ;
8081
8182 const incoming = [
@@ -93,8 +94,8 @@ describe("mergeAndDedup", () => {
9394 } ) ;
9495 } ) ;
9596
96- describe ( " edge cases" , ( ) => {
97- it ( " should handle empty existing array" , ( ) => {
97+ describe ( ' edge cases' , ( ) => {
98+ it ( ' should handle empty existing array' , ( ) => {
9899 const existing = [ ] as ApolloCacheItem [ ] ;
99100 const incoming = [ createRef ( 1 ) , createRef ( 2 ) ] ;
100101
@@ -103,7 +104,7 @@ describe("mergeAndDedup", () => {
103104 expect ( result ) . toEqual ( [ createRef ( 1 ) , createRef ( 2 ) ] ) ;
104105 } ) ;
105106
106- it ( " should handle empty incoming array" , ( ) => {
107+ it ( ' should handle empty incoming array' , ( ) => {
107108 const existing = [ createRef ( 1 ) , createRef ( 2 ) ] ;
108109 const incoming : ApolloCacheItem [ ] = [ ] ;
109110
@@ -112,15 +113,15 @@ describe("mergeAndDedup", () => {
112113 expect ( result ) . toEqual ( existing ) ;
113114 } ) ;
114115
115- it ( " should handle undefined existing array" , ( ) => {
116+ it ( ' should handle undefined existing array' , ( ) => {
116117 const incoming = [ createRef ( 1 ) , createRef ( 2 ) ] ;
117118
118119 const result = mergeAndDedup ( undefined , incoming , getRef , { offset : 0 } ) ;
119120
120121 expect ( result ) . toEqual ( incoming ) ;
121122 } ) ;
122123
123- it ( " should handle undefined args" , ( ) => {
124+ it ( ' should handle undefined args' , ( ) => {
124125 const existing = [ createRef ( 1 ) ] ;
125126 const incoming = [ createRef ( 2 ) ] ;
126127
@@ -129,7 +130,7 @@ describe("mergeAndDedup", () => {
129130 expect ( result ) . toEqual ( [ createRef ( 2 ) ] ) ;
130131 } ) ;
131132
132- it ( " should handle offset larger than existing array" , ( ) => {
133+ it ( ' should handle offset larger than existing array' , ( ) => {
133134 const existing = [ createRef ( 1 ) ] ;
134135 const incoming = [ createRef ( 2 ) ] ;
135136
@@ -139,8 +140,8 @@ describe("mergeAndDedup", () => {
139140 } ) ;
140141 } ) ;
141142
142- describe ( " multiple duplicates" , ( ) => {
143- it ( " should not overwrite multiple duplicates in incoming data" , ( ) => {
143+ describe ( ' multiple duplicates' , ( ) => {
144+ it ( ' should not overwrite multiple duplicates in incoming data' , ( ) => {
144145 const existing = [ createRef ( 1 ) , createRef ( 2 ) , createRef ( 3 ) ] ;
145146
146147 const incoming = [
@@ -154,7 +155,7 @@ describe("mergeAndDedup", () => {
154155 expect ( result ) . toEqual ( [ createRef ( 2 ) , createRef ( 3 ) , createRef ( 2 ) ] ) ;
155156 } ) ;
156157
157- it ( " should handle duplicates with gaps in offset" , ( ) => {
158+ it ( ' should handle duplicates with gaps in offset' , ( ) => {
158159 const existing = [ createRef ( 1 ) , createRef ( 2 ) , createRef ( 3 ) , createRef ( 4 ) ] ;
159160
160161 const incoming = [
0 commit comments