@@ -2424,4 +2424,176 @@ apiDescribe('Database', persistence => {
2424
2424
} ) ;
2425
2425
} ) ;
2426
2426
} ) ;
2427
+
2428
+ describe ( 'Unicode strings' , ( ) => {
2429
+ it ( 'snapshot listener sorts unicode strings the same as server' , async ( ) => {
2430
+ const testDocs = {
2431
+ 'a' : { value : 'Łukasiewicz' } ,
2432
+ 'b' : { value : 'Sierpiński' } ,
2433
+ 'c' : { value : '岩澤' } ,
2434
+ 'd' : { value : '🄟' } ,
2435
+ 'e' : { value : 'P' } ,
2436
+ 'f' : { value : '︒' } ,
2437
+ 'g' : { value : '🐵' }
2438
+ } ;
2439
+
2440
+ return withTestCollection ( persistence , testDocs , async collectionRef => {
2441
+ const orderedQuery = query ( collectionRef , orderBy ( 'value' ) ) ;
2442
+
2443
+ const getSnapshot = await getDocsFromServer ( orderedQuery ) ;
2444
+ expect ( toIds ( getSnapshot ) ) . to . deep . equal ( [
2445
+ 'b' ,
2446
+ 'a' ,
2447
+ 'c' ,
2448
+ 'f' ,
2449
+ 'e' ,
2450
+ 'd' ,
2451
+ 'g'
2452
+ ] ) ;
2453
+
2454
+ const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
2455
+ const unsubscribe = onSnapshot ( orderedQuery , storeEvent . storeEvent ) ;
2456
+ const watchSnapshot = await storeEvent . awaitEvent ( ) ;
2457
+ expect ( toIds ( watchSnapshot ) ) . to . deep . equal ( toIds ( getSnapshot ) ) ;
2458
+
2459
+ unsubscribe ( ) ;
2460
+ } ) ;
2461
+ } ) ;
2462
+
2463
+ it ( 'snapshot listener sorts unicode strings in array the same as server' , async ( ) => {
2464
+ const testDocs = {
2465
+ 'a' : { value : [ 'Łukasiewicz' ] } ,
2466
+ 'b' : { value : [ 'Sierpiński' ] } ,
2467
+ 'c' : { value : [ '岩澤' ] } ,
2468
+ 'd' : { value : [ '🄟' ] } ,
2469
+ 'e' : { value : [ 'P' ] } ,
2470
+ 'f' : { value : [ '︒' ] } ,
2471
+ 'g' : { value : [ '🐵' ] }
2472
+ } ;
2473
+
2474
+ return withTestCollection ( persistence , testDocs , async collectionRef => {
2475
+ const orderedQuery = query ( collectionRef , orderBy ( 'value' ) ) ;
2476
+
2477
+ const getSnapshot = await getDocsFromServer ( orderedQuery ) ;
2478
+ expect ( toIds ( getSnapshot ) ) . to . deep . equal ( [
2479
+ 'b' ,
2480
+ 'a' ,
2481
+ 'c' ,
2482
+ 'f' ,
2483
+ 'e' ,
2484
+ 'd' ,
2485
+ 'g'
2486
+ ] ) ;
2487
+
2488
+ const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
2489
+ const unsubscribe = onSnapshot ( orderedQuery , storeEvent . storeEvent ) ;
2490
+ const watchSnapshot = await storeEvent . awaitEvent ( ) ;
2491
+ expect ( toIds ( watchSnapshot ) ) . to . deep . equal ( toIds ( getSnapshot ) ) ;
2492
+
2493
+ unsubscribe ( ) ;
2494
+ } ) ;
2495
+ } ) ;
2496
+
2497
+ it ( 'snapshot listener sorts unicode strings in map the same as server' , async ( ) => {
2498
+ const testDocs = {
2499
+ 'a' : { value : { foo : 'Łukasiewicz' } } ,
2500
+ 'b' : { value : { foo : 'Sierpiński' } } ,
2501
+ 'c' : { value : { foo : '岩澤' } } ,
2502
+ 'd' : { value : { foo : '🄟' } } ,
2503
+ 'e' : { value : { foo : 'P' } } ,
2504
+ 'f' : { value : { foo : '︒' } } ,
2505
+ 'g' : { value : { foo : '🐵' } }
2506
+ } ;
2507
+
2508
+ return withTestCollection ( persistence , testDocs , async collectionRef => {
2509
+ const orderedQuery = query ( collectionRef , orderBy ( 'value' ) ) ;
2510
+
2511
+ const getSnapshot = await getDocsFromServer ( orderedQuery ) ;
2512
+ expect ( toIds ( getSnapshot ) ) . to . deep . equal ( [
2513
+ 'b' ,
2514
+ 'a' ,
2515
+ 'c' ,
2516
+ 'f' ,
2517
+ 'e' ,
2518
+ 'd' ,
2519
+ 'g'
2520
+ ] ) ;
2521
+
2522
+ const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
2523
+ const unsubscribe = onSnapshot ( orderedQuery , storeEvent . storeEvent ) ;
2524
+ const watchSnapshot = await storeEvent . awaitEvent ( ) ;
2525
+ expect ( toIds ( watchSnapshot ) ) . to . deep . equal ( toIds ( getSnapshot ) ) ;
2526
+
2527
+ unsubscribe ( ) ;
2528
+ } ) ;
2529
+ } ) ;
2530
+
2531
+ it ( 'snapshot listener sorts unicode strings in map key the same as server' , async ( ) => {
2532
+ const testDocs = {
2533
+ 'a' : { value : { 'Łukasiewicz' : true } } ,
2534
+ 'b' : { value : { 'Sierpiński' : true } } ,
2535
+ 'c' : { value : { '岩澤' : true } } ,
2536
+ 'd' : { value : { '🄟' : true } } ,
2537
+ 'e' : { value : { 'P' : true } } ,
2538
+ 'f' : { value : { '︒' : true } } ,
2539
+ 'g' : { value : { '🐵' : true } }
2540
+ } ;
2541
+
2542
+ return withTestCollection ( persistence , testDocs , async collectionRef => {
2543
+ const orderedQuery = query ( collectionRef , orderBy ( 'value' ) ) ;
2544
+
2545
+ const getSnapshot = await getDocsFromServer ( orderedQuery ) ;
2546
+ expect ( toIds ( getSnapshot ) ) . to . deep . equal ( [
2547
+ 'b' ,
2548
+ 'a' ,
2549
+ 'c' ,
2550
+ 'f' ,
2551
+ 'e' ,
2552
+ 'd' ,
2553
+ 'g'
2554
+ ] ) ;
2555
+
2556
+ const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
2557
+ const unsubscribe = onSnapshot ( orderedQuery , storeEvent . storeEvent ) ;
2558
+ const watchSnapshot = await storeEvent . awaitEvent ( ) ;
2559
+ expect ( toIds ( watchSnapshot ) ) . to . deep . equal ( toIds ( getSnapshot ) ) ;
2560
+
2561
+ unsubscribe ( ) ;
2562
+ } ) ;
2563
+ } ) ;
2564
+
2565
+ // it('snapshot listener sorts unicode strings in document key the same as server', async () => {
2566
+ // const testDocs = {
2567
+ // 'Łukasiewicz': { value: true },
2568
+ // 'Sierpiński': { value: true },
2569
+ // '岩澤': { value: true },
2570
+ // '🄟': { value: true },
2571
+ // 'P': { value: true },
2572
+ // '︒': { value: true },
2573
+ // '🐵': { value: true }
2574
+ // };
2575
+ //
2576
+ // return withTestCollection(persistence, testDocs, async collectionRef => {
2577
+ // const orderedQuery = query(collectionRef, orderBy('value'));
2578
+ //
2579
+ // const getSnapshot = await getDocsFromServer(orderedQuery);
2580
+ // expect(toIds(getSnapshot)).to.deep.equal([
2581
+ // 'Sierpiński',
2582
+ // 'Łukasiewicz',
2583
+ // '岩澤',
2584
+ // '︒',
2585
+ // 'P',
2586
+ // '🄟',
2587
+ // '🐵'
2588
+ // ]);
2589
+ //
2590
+ // const storeEvent = new EventsAccumulator<QuerySnapshot>();
2591
+ // const unsubscribe = onSnapshot(orderedQuery, storeEvent.storeEvent);
2592
+ // const watchSnapshot = await storeEvent.awaitEvent();
2593
+ // expect(toIds(watchSnapshot)).to.deep.equal(toIds(getSnapshot));
2594
+ //
2595
+ // unsubscribe();
2596
+ // });
2597
+ // });
2598
+ } ) ;
2427
2599
} ) ;
0 commit comments