@@ -2425,8 +2425,8 @@ apiDescribe('Database', persistence => {
2425
2425
} ) ;
2426
2426
} ) ;
2427
2427
2428
- describe ( 'Unicode strings' , ( ) => {
2429
- const expectedResult = [ 'b' , 'a' , 'c' , 'f' , 'e' , 'd' , 'g' ] ;
2428
+ describe ( 'Sort unicode strings' , ( ) => {
2429
+ const expectedDocs = [ 'b' , 'a' , 'c' , 'f' , 'e' , 'd' , 'g' ] ;
2430
2430
it ( 'snapshot listener sorts unicode strings the same as server' , async ( ) => {
2431
2431
const testDocs = {
2432
2432
'a' : { value : 'Łukasiewicz' } ,
@@ -2442,14 +2442,16 @@ apiDescribe('Database', persistence => {
2442
2442
const orderedQuery = query ( collectionRef , orderBy ( 'value' ) ) ;
2443
2443
2444
2444
const getSnapshot = await getDocsFromServer ( orderedQuery ) ;
2445
- expect ( toIds ( getSnapshot ) ) . to . deep . equal ( expectedResult ) ;
2445
+ expect ( toIds ( getSnapshot ) ) . to . deep . equal ( expectedDocs ) ;
2446
2446
2447
2447
const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
2448
2448
const unsubscribe = onSnapshot ( orderedQuery , storeEvent . storeEvent ) ;
2449
2449
const watchSnapshot = await storeEvent . awaitEvent ( ) ;
2450
2450
expect ( toIds ( watchSnapshot ) ) . to . deep . equal ( toIds ( getSnapshot ) ) ;
2451
2451
2452
2452
unsubscribe ( ) ;
2453
+
2454
+ await checkOnlineAndOfflineResultsMatch ( orderedQuery , ...expectedDocs ) ;
2453
2455
} ) ;
2454
2456
} ) ;
2455
2457
@@ -2468,14 +2470,16 @@ apiDescribe('Database', persistence => {
2468
2470
const orderedQuery = query ( collectionRef , orderBy ( 'value' ) ) ;
2469
2471
2470
2472
const getSnapshot = await getDocsFromServer ( orderedQuery ) ;
2471
- expect ( toIds ( getSnapshot ) ) . to . deep . equal ( expectedResult ) ;
2473
+ expect ( toIds ( getSnapshot ) ) . to . deep . equal ( expectedDocs ) ;
2472
2474
2473
2475
const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
2474
2476
const unsubscribe = onSnapshot ( orderedQuery , storeEvent . storeEvent ) ;
2475
2477
const watchSnapshot = await storeEvent . awaitEvent ( ) ;
2476
2478
expect ( toIds ( watchSnapshot ) ) . to . deep . equal ( toIds ( getSnapshot ) ) ;
2477
2479
2478
2480
unsubscribe ( ) ;
2481
+
2482
+ await checkOnlineAndOfflineResultsMatch ( orderedQuery , ...expectedDocs ) ;
2479
2483
} ) ;
2480
2484
} ) ;
2481
2485
@@ -2494,14 +2498,16 @@ apiDescribe('Database', persistence => {
2494
2498
const orderedQuery = query ( collectionRef , orderBy ( 'value' ) ) ;
2495
2499
2496
2500
const getSnapshot = await getDocsFromServer ( orderedQuery ) ;
2497
- expect ( toIds ( getSnapshot ) ) . to . deep . equal ( expectedResult ) ;
2501
+ expect ( toIds ( getSnapshot ) ) . to . deep . equal ( expectedDocs ) ;
2498
2502
2499
2503
const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
2500
2504
const unsubscribe = onSnapshot ( orderedQuery , storeEvent . storeEvent ) ;
2501
2505
const watchSnapshot = await storeEvent . awaitEvent ( ) ;
2502
2506
expect ( toIds ( watchSnapshot ) ) . to . deep . equal ( toIds ( getSnapshot ) ) ;
2503
2507
2504
2508
unsubscribe ( ) ;
2509
+
2510
+ await checkOnlineAndOfflineResultsMatch ( orderedQuery , ...expectedDocs ) ;
2505
2511
} ) ;
2506
2512
} ) ;
2507
2513
@@ -2520,14 +2526,16 @@ apiDescribe('Database', persistence => {
2520
2526
const orderedQuery = query ( collectionRef , orderBy ( 'value' ) ) ;
2521
2527
2522
2528
const getSnapshot = await getDocsFromServer ( orderedQuery ) ;
2523
- expect ( toIds ( getSnapshot ) ) . to . deep . equal ( expectedResult ) ;
2529
+ expect ( toIds ( getSnapshot ) ) . to . deep . equal ( expectedDocs ) ;
2524
2530
2525
2531
const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
2526
2532
const unsubscribe = onSnapshot ( orderedQuery , storeEvent . storeEvent ) ;
2527
2533
const watchSnapshot = await storeEvent . awaitEvent ( ) ;
2528
2534
expect ( toIds ( watchSnapshot ) ) . to . deep . equal ( toIds ( getSnapshot ) ) ;
2529
2535
2530
2536
unsubscribe ( ) ;
2537
+
2538
+ await checkOnlineAndOfflineResultsMatch ( orderedQuery , ...expectedDocs ) ;
2531
2539
} ) ;
2532
2540
} ) ;
2533
2541
@@ -2546,23 +2554,69 @@ apiDescribe('Database', persistence => {
2546
2554
const orderedQuery = query ( collectionRef , orderBy ( documentId ( ) ) ) ;
2547
2555
2548
2556
const getSnapshot = await getDocsFromServer ( orderedQuery ) ;
2549
- expect ( toIds ( getSnapshot ) ) . to . deep . equal ( [
2557
+ const expectedDocs = [
2550
2558
'Sierpiński' ,
2551
2559
'Łukasiewicz' ,
2552
2560
'岩澤' ,
2553
2561
'︒' ,
2554
2562
'P' ,
2555
2563
'🄟' ,
2556
2564
'🐵'
2557
- ] ) ;
2565
+ ] ;
2566
+ expect ( toIds ( getSnapshot ) ) . to . deep . equal ( expectedDocs ) ;
2558
2567
2559
2568
const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
2560
2569
const unsubscribe = onSnapshot ( orderedQuery , storeEvent . storeEvent ) ;
2561
2570
const watchSnapshot = await storeEvent . awaitEvent ( ) ;
2562
2571
expect ( toIds ( watchSnapshot ) ) . to . deep . equal ( toIds ( getSnapshot ) ) ;
2563
2572
2564
2573
unsubscribe ( ) ;
2574
+
2575
+ await checkOnlineAndOfflineResultsMatch ( orderedQuery , ...expectedDocs ) ;
2565
2576
} ) ;
2566
2577
} ) ;
2578
+
2579
+ // eslint-disable-next-line no-restricted-properties
2580
+ ( persistence . storage === 'indexeddb' ? it . skip : it ) (
2581
+ 'snapshot listener sorts unicode strings in document key the same as server with persistence' ,
2582
+ async ( ) => {
2583
+ const testDocs = {
2584
+ 'Łukasiewicz' : { value : true } ,
2585
+ 'Sierpiński' : { value : true } ,
2586
+ '岩澤' : { value : true } ,
2587
+ '🄟' : { value : true } ,
2588
+ 'P' : { value : true } ,
2589
+ '︒' : { value : true } ,
2590
+ '🐵' : { value : true }
2591
+ } ;
2592
+
2593
+ return withTestCollection (
2594
+ persistence ,
2595
+ testDocs ,
2596
+ async collectionRef => {
2597
+ const orderedQuery = query ( collectionRef , orderBy ( 'value' ) ) ;
2598
+
2599
+ const getSnapshot = await getDocsFromServer ( orderedQuery ) ;
2600
+ expect ( toIds ( getSnapshot ) ) . to . deep . equal ( [
2601
+ 'Sierpiński' ,
2602
+ 'Łukasiewicz' ,
2603
+ '岩澤' ,
2604
+ '︒' ,
2605
+ 'P' ,
2606
+ '🄟' ,
2607
+ '🐵'
2608
+ ] ) ;
2609
+
2610
+ const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
2611
+ const unsubscribe = onSnapshot ( orderedQuery , storeEvent . storeEvent ) ;
2612
+ const watchSnapshot = await storeEvent . awaitEvent ( ) ;
2613
+ // TODO: IndexedDB sorts string lexicographically, and misses the document with ID '🄟','🐵'
2614
+ expect ( toIds ( watchSnapshot ) ) . to . deep . equal ( toIds ( getSnapshot ) ) ;
2615
+
2616
+ unsubscribe ( ) ;
2617
+ }
2618
+ ) ;
2619
+ }
2620
+ ) ;
2567
2621
} ) ;
2568
2622
} ) ;
0 commit comments