@@ -4085,34 +4085,162 @@ describe('Query class', () => {
40854085 } ) ;
40864086 } ) ;
40874087
4088- it ( 'snapshot listener sorts query by unicode strings same way as server' , async ( ) => {
4089- const collection = await testCollectionWithDocs ( {
4090- a : { value : 'Łukasiewicz' } ,
4091- b : { value : 'Sierpiński' } ,
4092- c : { value : '岩澤' } ,
4093- d : { value : '🄟' } ,
4094- e : { value : 'P' } ,
4095- f : { value : '︒' } ,
4096- g : { value : '🐵' } ,
4097- } ) ;
4088+ describe ( 'sort unicode strings' , ( ) => {
4089+ it ( 'snapshot listener sorts query by unicode strings same as server' , async ( ) => {
4090+ const collection = await testCollectionWithDocs ( {
4091+ a : { value : 'Łukasiewicz' } ,
4092+ b : { value : 'Sierpiński' } ,
4093+ c : { value : '岩澤' } ,
4094+ d : { value : '🄟' } ,
4095+ e : { value : 'P' } ,
4096+ f : { value : '︒' } ,
4097+ g : { value : '🐵' } ,
4098+ } ) ;
40984099
4099- const query = collection . orderBy ( " value" ) ;
4100- const expectedDocs = [ 'b' , 'a' , 'c' , 'f' , 'e' , 'd' , 'g' ] ;
4100+ const query = collection . orderBy ( ' value' ) ;
4101+ const expectedDocs = [ 'b' , 'a' , 'c' , 'f' , 'e' , 'd' , 'g' ] ;
41014102
4102- const getSnapshot = await query . get ( ) ;
4103- expect ( getSnapshot . docs . map ( d => d . id ) ) . to . deep . equal ( expectedDocs ) ;
4103+ const getSnapshot = await query . get ( ) ;
4104+ expect ( getSnapshot . docs . map ( d => d . id ) ) . to . deep . equal ( expectedDocs ) ;
41044105
4105- const unsubscribe = query . onSnapshot ( snapshot =>
4106- currentDeferred . resolve ( snapshot )
4107- ) ;
4106+ const unsubscribe = query . onSnapshot ( snapshot =>
4107+ currentDeferred . resolve ( snapshot )
4108+ ) ;
41084109
4109- const watchSnapshot = await waitForSnapshot ( ) ;
4110- // Compare the snapshot (including sort order) of a snapshot
4111- snapshotsEqual ( watchSnapshot , {
4112- docs : getSnapshot . docs ,
4113- docChanges : getSnapshot . docChanges ( ) ,
4110+ const watchSnapshot = await waitForSnapshot ( ) ;
4111+ // Compare the snapshot (including sort order) of a snapshot
4112+ snapshotsEqual ( watchSnapshot , {
4113+ docs : getSnapshot . docs ,
4114+ docChanges : getSnapshot . docChanges ( ) ,
4115+ } ) ;
4116+ unsubscribe ( ) ;
4117+ } ) ;
4118+
4119+ it ( 'snapshot listener sorts query by unicode strings in array same as server' , async ( ) => {
4120+ const collection = await testCollectionWithDocs ( {
4121+ a : { value : [ 'Łukasiewicz' ] } ,
4122+ b : { value : [ 'Sierpiński' ] } ,
4123+ c : { value : [ '岩澤' ] } ,
4124+ d : { value : [ '🄟' ] } ,
4125+ e : { value : [ 'P' ] } ,
4126+ f : { value : [ '︒' ] } ,
4127+ g : { value : [ '🐵' ] } ,
4128+ } ) ;
4129+
4130+ const query = collection . orderBy ( 'value' ) ;
4131+ const expectedDocs = [ 'b' , 'a' , 'c' , 'f' , 'e' , 'd' , 'g' ] ;
4132+
4133+ const getSnapshot = await query . get ( ) ;
4134+ expect ( getSnapshot . docs . map ( d => d . id ) ) . to . deep . equal ( expectedDocs ) ;
4135+
4136+ const unsubscribe = query . onSnapshot ( snapshot =>
4137+ currentDeferred . resolve ( snapshot )
4138+ ) ;
4139+
4140+ const watchSnapshot = await waitForSnapshot ( ) ;
4141+ snapshotsEqual ( watchSnapshot , {
4142+ docs : getSnapshot . docs ,
4143+ docChanges : getSnapshot . docChanges ( ) ,
4144+ } ) ;
4145+ unsubscribe ( ) ;
4146+ } ) ;
4147+
4148+ it ( 'snapshot listener sorts query by unicode strings in map same as server' , async ( ) => {
4149+ const collection = await testCollectionWithDocs ( {
4150+ a : { value : { foo : 'Łukasiewicz' } } ,
4151+ b : { value : { foo : 'Sierpiński' } } ,
4152+ c : { value : { foo : '岩澤' } } ,
4153+ d : { value : { foo : '🄟' } } ,
4154+ e : { value : { foo : 'P' } } ,
4155+ f : { value : { foo : '︒' } } ,
4156+ g : { value : { foo : '🐵' } } ,
4157+ } ) ;
4158+
4159+ const query = collection . orderBy ( 'value' ) ;
4160+ const expectedDocs = [ 'b' , 'a' , 'c' , 'f' , 'e' , 'd' , 'g' ] ;
4161+
4162+ const getSnapshot = await query . get ( ) ;
4163+ expect ( getSnapshot . docs . map ( d => d . id ) ) . to . deep . equal ( expectedDocs ) ;
4164+
4165+ const unsubscribe = query . onSnapshot ( snapshot =>
4166+ currentDeferred . resolve ( snapshot )
4167+ ) ;
4168+
4169+ const watchSnapshot = await waitForSnapshot ( ) ;
4170+ // Compare the snapshot (including sort order) of a snapshot
4171+ snapshotsEqual ( watchSnapshot , {
4172+ docs : getSnapshot . docs ,
4173+ docChanges : getSnapshot . docChanges ( ) ,
4174+ } ) ;
4175+ unsubscribe ( ) ;
4176+ } ) ;
4177+ it ( 'snapshot listener sorts query by unicode strings in map key same as server' , async ( ) => {
4178+ const collection = await testCollectionWithDocs ( {
4179+ a : { value : { Łukasiewicz : true } } ,
4180+ b : { value : { Sierpiński : true } } ,
4181+ c : { value : { 岩澤 : true } } ,
4182+ d : { value : { '🄟' : true } } ,
4183+ e : { value : { P : true } } ,
4184+ f : { value : { '︒' : true } } ,
4185+ g : { value : { '🐵' : true } } ,
4186+ } ) ;
4187+
4188+ const query = collection . orderBy ( 'value' ) ;
4189+ const expectedDocs = [ 'b' , 'a' , 'c' , 'f' , 'e' , 'd' , 'g' ] ;
4190+
4191+ const getSnapshot = await query . get ( ) ;
4192+ expect ( getSnapshot . docs . map ( d => d . id ) ) . to . deep . equal ( expectedDocs ) ;
4193+
4194+ const unsubscribe = query . onSnapshot ( snapshot =>
4195+ currentDeferred . resolve ( snapshot )
4196+ ) ;
4197+
4198+ const watchSnapshot = await waitForSnapshot ( ) ;
4199+ // Compare the snapshot (including sort order) of a snapshot
4200+ snapshotsEqual ( watchSnapshot , {
4201+ docs : getSnapshot . docs ,
4202+ docChanges : getSnapshot . docChanges ( ) ,
4203+ } ) ;
4204+ unsubscribe ( ) ;
4205+ } ) ;
4206+
4207+ it ( 'snapshot listener sorts query by unicode strings in document key same as server' , async ( ) => {
4208+ const collection = await testCollectionWithDocs ( {
4209+ Łukasiewicz : { value : true } ,
4210+ Sierpiński : { value : true } ,
4211+ 岩澤 : { value : true } ,
4212+ '🄟' : { value : true } ,
4213+ P : { value : true } ,
4214+ '︒' : { value : true } ,
4215+ '🐵' : { value : true } ,
4216+ } ) ;
4217+
4218+ const query = collection . orderBy ( 'value' ) ;
4219+ const expectedDocs = [
4220+ 'Sierpiński' ,
4221+ 'Łukasiewicz' ,
4222+ '岩澤' ,
4223+ '︒' ,
4224+ 'P' ,
4225+ '🄟' ,
4226+ '🐵' ,
4227+ ] ;
4228+
4229+ const getSnapshot = await query . get ( ) ;
4230+ expect ( getSnapshot . docs . map ( d => d . id ) ) . to . deep . equal ( expectedDocs ) ;
4231+
4232+ const unsubscribe = query . onSnapshot ( snapshot =>
4233+ currentDeferred . resolve ( snapshot )
4234+ ) ;
4235+
4236+ const watchSnapshot = await waitForSnapshot ( ) ;
4237+ // Compare the snapshot (including sort order) of a snapshot
4238+ snapshotsEqual ( watchSnapshot , {
4239+ docs : getSnapshot . docs ,
4240+ docChanges : getSnapshot . docChanges ( ) ,
4241+ } ) ;
4242+ unsubscribe ( ) ;
41144243 } ) ;
4115- unsubscribe ( ) ;
41164244 } ) ;
41174245 } ) ;
41184246
0 commit comments