@@ -5,21 +5,19 @@ import { createSearchKey, createSearchKeys, findMatches } from "./search";
55import type { Store } from "$lib/types/store" ;
66
77const createStore = ( overrides : Partial < Store > = { } ) : Store => ( {
8- l : "" ,
98 n : "" ,
109 u : "" ,
11- c : "" ,
1210 s30 : 0 ,
13- sav : 0 ,
14- aff : "" ,
15- cc : 0 ,
11+ a30 : 0 ,
12+ p : 0 ,
13+ c : 0 ,
1614 ...overrides
1715} ) ;
1816
1917describe ( "createSearchKey" , ( ) => {
20- it ( "combines name, url, and country into lowercase key" , ( ) => {
21- const store = createStore ( { n : "Amazon" , u : "amazon.com" , c : "US" } ) ;
22- expect ( createSearchKey ( store ) ) . toBe ( "amazon amazon.com us " ) ;
18+ it ( "combines name and url into lowercase key" , ( ) => {
19+ const store = createStore ( { n : "Amazon" , u : "amazon.com" } ) ;
20+ expect ( createSearchKey ( store ) ) . toBe ( "amazon amazon.com" ) ;
2321 } ) ;
2422
2523 it ( "handles missing fields gracefully" , ( ) => {
@@ -59,11 +57,11 @@ describe("createSearchKeys", () => {
5957
6058describe ( "findMatches" , ( ) => {
6159 const stores = [
62- createStore ( { n : "Amazon" , u : "amazon.com" , c : "US" } ) ,
63- createStore ( { n : "Amazon UK" , u : "amazon.co.uk" , c : "UK" } ) ,
64- createStore ( { n : "Walmart" , u : "walmart.com" , c : "US" } ) ,
65- createStore ( { n : "Best Buy" , u : "bestbuy.com" , c : "US" } ) ,
66- createStore ( { n : "Target" , u : "target.com" , c : "US" } )
60+ createStore ( { n : "Amazon" , u : "amazon.com" } ) ,
61+ createStore ( { n : "Amazon UK" , u : "amazon.co.uk" } ) ,
62+ createStore ( { n : "Walmart" , u : "walmart.com" } ) ,
63+ createStore ( { n : "Best Buy" , u : "bestbuy.com" } ) ,
64+ createStore ( { n : "Target" , u : "target.com" } )
6765 ] ;
6866 const keys = createSearchKeys ( stores ) ;
6967 const allIndices = [ 0 , 1 , 2 , 3 , 4 ] ;
@@ -93,14 +91,8 @@ describe("findMatches", () => {
9391 expect ( stores [ results [ 0 ] ] . n ) . toBe ( "Best Buy" ) ;
9492 } ) ;
9593
96- it ( "matches by country" , ( ) => {
97- const results = findMatches ( allIndices , keys , "uk" , 100 ) ;
98- expect ( results ) . toHaveLength ( 1 ) ;
99- expect ( stores [ results [ 0 ] ] . n ) . toBe ( "Amazon UK" ) ;
100- } ) ;
101-
10294 it ( "respects maxResults limit" , ( ) => {
103- const results = findMatches ( allIndices , keys , "us " , 2 ) ;
95+ const results = findMatches ( allIndices , keys , "m " , 2 ) ;
10496 expect ( results ) . toHaveLength ( 2 ) ;
10597 } ) ;
10698
0 commit comments