Skip to content

Commit 0489bcc

Browse files
crud test
1 parent b7d6a8c commit 0489bcc

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

packages/compass-crud/src/stores/crud-store.spec.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)