@@ -1663,7 +1663,8 @@ describe('store', function () {
16631663 const plugin = activatePlugin ( ) ;
16641664 store = plugin . store ;
16651665 deactivate = ( ) => plugin . deactivate ( ) ;
1666- await dataService . insertOne ( 'compass-crud.test' , { name : 'testing' } ) ;
1666+ await dataService . insertOne ( 'compass-crud.test' , { name : 'testing1' } ) ;
1667+ await dataService . insertOne ( 'compass-crud.test' , { name : 'testing2' } ) ;
16671668 } ) ;
16681669
16691670 afterEach ( function ( ) {
@@ -1680,9 +1681,36 @@ describe('store', function () {
16801681
16811682 ( state ) => {
16821683 expect ( state . error ) . to . equal ( null ) ;
1683- expect ( state . docs ) . to . have . length ( 1 ) ;
1684+ expect ( state . docs ) . to . have . length ( 2 ) ;
1685+ expect ( state . docs [ 0 ] . doc . name ) . to . equal ( 'testing1' ) ;
16841686 expect ( state . debouncingLoad ) . to . equal ( false ) ;
1685- expect ( state . count ) . to . equal ( 1 ) ;
1687+ expect ( state . count ) . to . equal ( 2 ) ;
1688+ expect ( state . start ) . to . equal ( 1 ) ;
1689+ expect ( state . shardKeys ) . to . deep . equal ( { } ) ;
1690+ } ,
1691+ ] ) ;
1692+
1693+ void store . refreshDocuments ( ) ;
1694+
1695+ await listener ;
1696+ } ) ;
1697+
1698+ it ( 'uses the sort order from preferences' , async function ( ) {
1699+ await preferences . savePreferences ( {
1700+ defaultSortOrder : '{ _id: -1 }' ,
1701+ } ) ;
1702+ const listener = waitForStates ( store , [
1703+ ( state ) => {
1704+ expect ( state . debouncingLoad ) . to . equal ( true ) ;
1705+ expect ( state . count ) . to . equal ( null ) ;
1706+ } ,
1707+
1708+ ( state ) => {
1709+ expect ( state . error ) . to . equal ( null ) ;
1710+ expect ( state . docs ) . to . have . length ( 2 ) ;
1711+ expect ( state . docs [ 0 ] . doc . name ) . to . equal ( 'testing2' ) ;
1712+ expect ( state . debouncingLoad ) . to . equal ( false ) ;
1713+ expect ( state . count ) . to . equal ( 2 ) ;
16861714 expect ( state . start ) . to . equal ( 1 ) ;
16871715 expect ( state . shardKeys ) . to . deep . equal ( { } ) ;
16881716 } ,
0 commit comments