Skip to content

Commit 6808f8c

Browse files
committed
Fix types in tests
1 parent e8de894 commit 6808f8c

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

packages/electric-db-collection/src/tag-index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export type ParsedMoveTag = Array<string>
77
export type Position = number
88
export type Value = string
99
export type MoveOutPattern = {
10-
position: Position
10+
pos: Position
1111
value: Value
1212
}
1313

@@ -54,8 +54,8 @@ export function getValue(tag: ParsedMoveTag, position: Position): Value {
5454
/**
5555
* Abstraction to extract position and value from a pattern.
5656
*/
57-
export function getPositionalValue(pattern: MoveOutPattern): {
58-
position: number
57+
function getPositionalValue(pattern: MoveOutPattern): {
58+
pos: number
5959
value: string
6060
} {
6161
return pattern
@@ -77,8 +77,8 @@ export function tagMatchesPattern(
7777
tag: ParsedMoveTag,
7878
pattern: MoveOutPattern
7979
): boolean {
80-
const { position, value } = getPositionalValue(pattern)
81-
const tagValue = getValue(tag, position)
80+
const { pos, value } = getPositionalValue(pattern)
81+
const tagValue = getValue(tag, pos)
8282
return tagValue === value || tagValue === TAG_WILDCARD
8383
}
8484

@@ -144,8 +144,8 @@ export function findRowsMatchingPattern(
144144
pattern: MoveOutPattern,
145145
index: TagIndex
146146
): Set<RowId> {
147-
const { position, value } = getPositionalValue(pattern)
148-
const positionIndex = index[position]
147+
const { pos, value } = getPositionalValue(pattern)
148+
const positionIndex = index[pos]
149149
const rowSet = positionIndex?.get(value)
150150
return rowSet ?? new Set()
151151
}

packages/electric-db-collection/tests/tags.test.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ describe(`Electric Tag Tracking and GC`, () => {
637637

638638
// Send move-out event with pattern matching hash1 at position 0
639639
const pattern: MoveOutPattern = {
640-
position: 0,
640+
pos: 0,
641641
value: `hash1`,
642642
}
643643

@@ -646,7 +646,7 @@ describe(`Electric Tag Tracking and GC`, () => {
646646
headers: {
647647
event: `move-out`,
648648
patterns: [pattern],
649-
} as any, // TODO: remove this when pushing to CI
649+
},
650650
},
651651
{
652652
headers: { control: `up-to-date` },
@@ -709,7 +709,7 @@ describe(`Electric Tag Tracking and GC`, () => {
709709
// Send move-out event matching sharedTag1 (hash1 at position 0)
710710
// This should remove sharedTag1 from both row 1 and row 2
711711
const pattern: MoveOutPattern = {
712-
position: 0,
712+
pos: 0,
713713
value: `hash1`,
714714
}
715715

@@ -718,7 +718,7 @@ describe(`Electric Tag Tracking and GC`, () => {
718718
headers: {
719719
event: `move-out`,
720720
patterns: [pattern],
721-
} as any, // TODO: remove this when pushing to CI
721+
},
722722
},
723723
{
724724
headers: { control: `up-to-date` },
@@ -738,7 +738,7 @@ describe(`Electric Tag Tracking and GC`, () => {
738738
// Send move-out event matching sharedTag2 (hash4 at position 0)
739739
// This should remove sharedTag2 from both row 2 and row 3
740740
const pattern2: MoveOutPattern = {
741-
position: 0,
741+
pos: 0,
742742
value: `hash4`,
743743
}
744744

@@ -747,7 +747,7 @@ describe(`Electric Tag Tracking and GC`, () => {
747747
headers: {
748748
event: `move-out`,
749749
patterns: [pattern2],
750-
} as any, // TODO: remove this when pushing to CI
750+
},
751751
},
752752
{
753753
headers: { control: `up-to-date` },
@@ -765,7 +765,7 @@ describe(`Electric Tag Tracking and GC`, () => {
765765
// Send move-out event matching uniqueTag1 (hash7 at position 0)
766766
// This should remove uniqueTag1 from row 1
767767
const pattern3: MoveOutPattern = {
768-
position: 0,
768+
pos: 0,
769769
value: `hash7`,
770770
}
771771

@@ -774,7 +774,7 @@ describe(`Electric Tag Tracking and GC`, () => {
774774
headers: {
775775
event: `move-out`,
776776
patterns: [pattern3],
777-
} as any, // TODO: remove this when pushing to CI
777+
},
778778
},
779779
{
780780
headers: { control: `up-to-date` },
@@ -816,7 +816,7 @@ describe(`Electric Tag Tracking and GC`, () => {
816816
// Since the tag is not indexed at position 1, it won't be found in the index
817817
// and the tag should remain
818818
const patternNonIndexed: MoveOutPattern = {
819-
position: 1,
819+
pos: 1,
820820
value: `b`,
821821
}
822822

@@ -825,7 +825,7 @@ describe(`Electric Tag Tracking and GC`, () => {
825825
headers: {
826826
event: `move-out`,
827827
patterns: [patternNonIndexed],
828-
} as any, // TODO: remove this when pushing to CI
828+
},
829829
},
830830
{
831831
headers: { control: `up-to-date` },
@@ -840,7 +840,7 @@ describe(`Electric Tag Tracking and GC`, () => {
840840
// Position 2 is indexed (has value 'c'), so it will be found in the index
841841
// The pattern matching position 2 with value 'c' matches the tag a|_|c, so the tag is removed
842842
const patternIndexed: MoveOutPattern = {
843-
position: 2,
843+
pos: 2,
844844
value: `c`,
845845
}
846846

@@ -849,7 +849,7 @@ describe(`Electric Tag Tracking and GC`, () => {
849849
headers: {
850850
event: `move-out`,
851851
patterns: [patternIndexed],
852-
} as any, // TODO: remove this when pushing to CI
852+
},
853853
},
854854
{
855855
headers: { control: `up-to-date` },
@@ -902,11 +902,11 @@ describe(`Electric Tag Tracking and GC`, () => {
902902

903903
// Send move-out event with multiple patterns
904904
const pattern1: MoveOutPattern = {
905-
position: 0,
905+
pos: 0,
906906
value: `hash1`,
907907
}
908908
const pattern2: MoveOutPattern = {
909-
position: 0,
909+
pos: 0,
910910
value: `hash4`,
911911
}
912912

@@ -915,7 +915,7 @@ describe(`Electric Tag Tracking and GC`, () => {
915915
headers: {
916916
event: `move-out`,
917917
patterns: [pattern1, pattern2],
918-
} as any, // TODO: remove this when pushing to CI
918+
},
919919
},
920920
{
921921
headers: { control: `up-to-date` },
@@ -987,7 +987,7 @@ describe(`Electric Tag Tracking and GC`, () => {
987987
headers: {
988988
operation: `insert`,
989989
tags: [tag2],
990-
} as any, // TODO: remove this when pushing to CI
990+
},
991991
},
992992
{
993993
headers: { control: `up-to-date` },
@@ -1009,7 +1009,7 @@ describe(`Electric Tag Tracking and GC`, () => {
10091009
headers: {
10101010
operation: `delete`,
10111011
removed_tags: [tag2],
1012-
} as any, // TODO: remove this when pushing to CI
1012+
},
10131013
},
10141014
{
10151015
headers: { control: `up-to-date` },
@@ -1089,13 +1089,13 @@ describe(`Electric Tag Tracking and GC`, () => {
10891089

10901090
// Move out that matches the tag
10911091
const pattern: MoveOutPattern = {
1092-
position: 1,
1092+
pos: 1,
10931093
value: `hash2`,
10941094
}
10951095

10961096
subscriber([
10971097
{
1098-
headers: { event: `move-out`, patterns: [pattern] } as any, // TODO: remove this when pushing to CI
1098+
headers: { event: `move-out`, patterns: [pattern] },
10991099
},
11001100
{
11011101
headers: { control: `up-to-date` },

0 commit comments

Comments
 (0)