@@ -529,7 +529,7 @@ describe('store', function () {
529529 beforeEach ( function ( ) {
530530 sinon
531531 . stub ( dataService , 'deleteOne' )
532- . yields ( { message : 'error happened' } ) ;
532+ . rejects ( { message : 'error happened' } ) ;
533533 } ) ;
534534
535535 it ( 'sets the error for the document' , function ( done ) {
@@ -547,7 +547,7 @@ describe('store', function () {
547547 let store ;
548548 let actions ;
549549
550- beforeEach ( function ( done ) {
550+ beforeEach ( async function ( ) {
551551 actions = configureActions ( ) ;
552552 store = configureStore ( {
553553 localAppRegistry : localAppRegistry ,
@@ -559,19 +559,14 @@ describe('store', function () {
559559 actions : actions ,
560560 namespace : 'compass-crud.test' ,
561561 } ) ;
562- dataService . insertOne (
563- 'compass-crud.test' ,
564- {
565- _id : 'testing' ,
566- name : 'Depeche Mode' ,
567- } ,
568- { } ,
569- done
570- ) ;
562+ await dataService . insertOne ( 'compass-crud.test' , {
563+ _id : 'testing' ,
564+ name : 'Depeche Mode' ,
565+ } ) ;
571566 } ) ;
572567
573- afterEach ( function ( done ) {
574- dataService . deleteMany ( 'compass-crud.test' , { } , { } , done ) ;
568+ afterEach ( function ( ) {
569+ return dataService . deleteMany ( 'compass-crud.test' , { } ) ;
575570 } ) ;
576571
577572 context ( 'when there is no error' , function ( ) {
@@ -996,8 +991,8 @@ describe('store', function () {
996991 } ) ;
997992
998993 context ( 'when there is no error' , function ( ) {
999- afterEach ( function ( done ) {
1000- dataService . deleteMany ( 'compass-crud.test' , { } , { } , done ) ;
994+ afterEach ( function ( ) {
995+ return dataService . deleteMany ( 'compass-crud.test' , { } ) ;
1001996 } ) ;
1002997
1003998 context ( 'when the document matches the filter' , function ( ) {
@@ -1060,8 +1055,8 @@ describe('store', function () {
10601055 store . state . insert . jsonDoc = jsonDoc ;
10611056 } ) ;
10621057
1063- afterEach ( function ( done ) {
1064- dataService . deleteMany ( 'compass-crud.test' , { } , { } , done ) ;
1058+ afterEach ( function ( ) {
1059+ return dataService . deleteMany ( 'compass-crud.test' , { } ) ;
10651060 } ) ;
10661061
10671062 it ( 'does not insert the document' , async function ( ) {
@@ -1090,8 +1085,8 @@ describe('store', function () {
10901085 store . state . insert . jsonDoc = jsonDoc ;
10911086 } ) ;
10921087
1093- afterEach ( function ( done ) {
1094- dataService . deleteMany ( 'compass-crud.test' , { } , { } , done ) ;
1088+ afterEach ( function ( ) {
1089+ return dataService . deleteMany ( 'compass-crud.test' , { } ) ;
10951090 } ) ;
10961091
10971092 it ( 'does not insert the document' , async function ( ) {
@@ -1134,8 +1129,8 @@ describe('store', function () {
11341129 } ) ;
11351130
11361131 context ( 'when there is no error' , function ( ) {
1137- afterEach ( function ( done ) {
1138- dataService . deleteMany ( 'compass-crud.test' , { } , { } , done ) ;
1132+ afterEach ( function ( ) {
1133+ return dataService . deleteMany ( 'compass-crud.test' , { } ) ;
11391134 } ) ;
11401135
11411136 context ( 'when the documents match the filter' , function ( ) {
@@ -1257,8 +1252,8 @@ describe('store', function () {
12571252 store . state . insert . jsonDoc = JSON . stringify ( docs ) ;
12581253 } ) ;
12591254
1260- afterEach ( function ( done ) {
1261- dataService . deleteMany ( 'compass-crud.test' , { } , { } , done ) ;
1255+ afterEach ( function ( ) {
1256+ return dataService . deleteMany ( 'compass-crud.test' , { } ) ;
12621257 } ) ;
12631258
12641259 it ( 'does not insert the document' , async function ( ) {
@@ -1562,7 +1557,7 @@ describe('store', function () {
15621557 let store ;
15631558 let actions ;
15641559
1565- beforeEach ( function ( done ) {
1560+ beforeEach ( async function ( ) {
15661561 actions = configureActions ( ) ;
15671562 store = configureStore ( {
15681563 localAppRegistry : localAppRegistry ,
@@ -1575,16 +1570,11 @@ describe('store', function () {
15751570 namespace : 'compass-crud.test' ,
15761571 noRefreshOnConfigure : true ,
15771572 } ) ;
1578- dataService . insertOne (
1579- 'compass-crud.test' ,
1580- { name : 'testing' } ,
1581- { } ,
1582- done
1583- ) ;
1573+ await dataService . insertOne ( 'compass-crud.test' , { name : 'testing' } ) ;
15841574 } ) ;
15851575
1586- afterEach ( function ( done ) {
1587- dataService . deleteMany ( 'compass-crud.test' , { } , { } , done ) ;
1576+ afterEach ( function ( ) {
1577+ return dataService . deleteMany ( 'compass-crud.test' , { } ) ;
15881578 } ) ;
15891579
15901580 context ( 'when there is no error' , function ( ) {
@@ -1639,7 +1629,7 @@ describe('store', function () {
16391629 let store ;
16401630 let actions ;
16411631
1642- beforeEach ( function ( done ) {
1632+ beforeEach ( async function ( ) {
16431633 actions = configureActions ( ) ;
16441634 store = configureStore ( {
16451635 localAppRegistry : localAppRegistry ,
@@ -1652,21 +1642,16 @@ describe('store', function () {
16521642 namespace : 'compass-crud.test' ,
16531643 noRefreshOnConfigure : true ,
16541644 } ) ;
1655- dataService . insertOne (
1656- 'config.collections' ,
1657- { _id : 'compass-crud.test' , key : { a : 1 } } ,
1658- { } ,
1659- done
1660- ) ;
1645+ await dataService . insertOne ( 'config.collections' , {
1646+ _id : 'compass-crud.test' ,
1647+ key : { a : 1 } ,
1648+ } ) ;
16611649 } ) ;
16621650
1663- afterEach ( function ( done ) {
1664- dataService . deleteMany (
1665- 'config.collections' ,
1666- { _id : 'compass-crud.test' } ,
1667- { } ,
1668- done
1669- ) ;
1651+ afterEach ( function ( ) {
1652+ return dataService . deleteMany ( 'config.collections' , {
1653+ _id : 'compass-crud.test' ,
1654+ } ) ;
16701655 } ) ;
16711656
16721657 it ( 'looks up the shard keys' , async function ( ) {
@@ -1685,7 +1670,7 @@ describe('store', function () {
16851670 let store ;
16861671 let actions ;
16871672
1688- beforeEach ( function ( done ) {
1673+ beforeEach ( async function ( ) {
16891674 actions = configureActions ( ) ;
16901675 store = configureStore ( {
16911676 query : { project : { _id : 0 } } ,
@@ -1701,16 +1686,11 @@ describe('store', function () {
17011686 } ) ;
17021687
17031688 store . setState ( { query : { project : { _id : 0 } } } ) ;
1704- dataService . insertOne (
1705- 'compass-crud.test' ,
1706- { name : 'testing' } ,
1707- { } ,
1708- done
1709- ) ;
1689+ await dataService . insertOne ( 'compass-crud.test' , { name : 'testing' } ) ;
17101690 } ) ;
17111691
1712- afterEach ( function ( done ) {
1713- dataService . deleteMany ( 'compass-crud.test' , { } , { } , done ) ;
1692+ afterEach ( function ( ) {
1693+ return dataService . deleteMany ( 'compass-crud.test' , { } ) ;
17141694 } ) ;
17151695
17161696 it ( 'sets the state as not editable' , async function ( ) {
@@ -1728,7 +1708,7 @@ describe('store', function () {
17281708 let store ;
17291709 let actions ;
17301710
1731- beforeEach ( function ( done ) {
1711+ beforeEach ( async function ( ) {
17321712 actions = configureActions ( ) ;
17331713 store = configureStore ( {
17341714 localAppRegistry : localAppRegistry ,
@@ -1743,16 +1723,11 @@ describe('store', function () {
17431723 } ) ;
17441724
17451725 store . setState ( { isEditable : false } ) ;
1746- dataService . insertOne (
1747- 'compass-crud.test' ,
1748- { name : 'testing' } ,
1749- { } ,
1750- done
1751- ) ;
1726+ await dataService . insertOne ( 'compass-crud.test' , { name : 'testing' } ) ;
17521727 } ) ;
17531728
1754- afterEach ( function ( done ) {
1755- dataService . deleteMany ( 'compass-crud.test' , { } , { } , done ) ;
1729+ afterEach ( function ( ) {
1730+ return dataService . deleteMany ( 'compass-crud.test' , { } ) ;
17561731 } ) ;
17571732
17581733 it ( 'resets the state as editable' , async function ( ) {
@@ -1883,7 +1858,7 @@ describe('store', function () {
18831858 let actions ;
18841859 let findSpy ;
18851860
1886- beforeEach ( function ( done ) {
1861+ beforeEach ( async function ( ) {
18871862 actions = configureActions ( ) ;
18881863 store = configureStore ( {
18891864 localAppRegistry : localAppRegistry ,
@@ -1900,11 +1875,11 @@ describe('store', function () {
19001875 findSpy = sinon . spy ( store . dataService , 'find' ) ;
19011876
19021877 const docs = [ ...Array ( 1000 ) . keys ( ) ] . map ( ( i ) => ( { i } ) ) ;
1903- dataService . insertMany ( 'compass-crud.test' , docs , { } , done ) ;
1878+ await dataService . insertMany ( 'compass-crud.test' , docs ) ;
19041879 } ) ;
19051880
1906- afterEach ( function ( done ) {
1907- dataService . deleteMany ( 'compass-crud.test' , { } , { } , done ) ;
1881+ afterEach ( function ( ) {
1882+ return dataService . deleteMany ( 'compass-crud.test' , { } ) ;
19081883 } ) ;
19091884
19101885 it ( 'does nothing for negative page numbers' , async function ( ) {
@@ -1985,7 +1960,7 @@ describe('store', function () {
19851960 let store ;
19861961 let actions ;
19871962
1988- beforeEach ( function ( done ) {
1963+ beforeEach ( async function ( ) {
19891964 actions = configureActions ( ) ;
19901965 store = configureStore ( {
19911966 localAppRegistry : localAppRegistry ,
@@ -1998,44 +1973,23 @@ describe('store', function () {
19981973 namespace : 'compass-crud.testview' ,
19991974 noRefreshOnConfigure : true ,
20001975 } ) ;
2001- dataService . insertMany (
1976+ await dataService . insertMany ( 'compass-crud.test' , [
1977+ { _id : '001' , cat : 'nori' } ,
1978+ { _id : '002' , cat : 'chashu' } ,
1979+ { _id : '003' , cat : 'amy' } ,
1980+ { _id : '004' , cat : 'pia' } ,
1981+ ] ) ;
1982+ await dataService . createView (
1983+ 'testview' ,
20021984 'compass-crud.test' ,
2003- [
2004- { _id : '001' , cat : 'nori' } ,
2005- { _id : '002' , cat : 'chashu' } ,
2006- { _id : '003' , cat : 'amy' } ,
2007- { _id : '004' , cat : 'pia' } ,
2008- ] ,
2009- { } ,
2010- ( err ) => {
2011- if ( err ) {
2012- return done ( err ) ;
2013- }
2014-
2015- dataService
2016- . createView (
2017- 'testview' ,
2018- 'compass-crud.test' ,
2019- [ { $sort : { cat : 1 } } ] ,
2020- { }
2021- )
2022- . then (
2023- ( ) => {
2024- done ( ) ;
2025- } ,
2026- ( createViewError ) => {
2027- done ( createViewError ) ;
2028- }
2029- ) ;
2030- }
1985+ [ { $sort : { cat : 1 } } ] ,
1986+ { }
20311987 ) ;
20321988 } ) ;
20331989
2034- afterEach ( function ( done ) {
2035- dataService . deleteMany ( 'compass-crud.test' , { } , { } , ( err ) => {
2036- if ( err ) return done ( err ) ;
2037- dataService . dropView ( 'compass-crud.testview' , done ) ;
2038- } ) ;
1990+ afterEach ( async function ( ) {
1991+ await dataService . deleteMany ( 'compass-crud.test' , { } ) ;
1992+ await dataService . dropCollection ( 'compass-crud.testview' ) ;
20391993 } ) ;
20401994
20411995 it ( 'returns documents in view order' , async function ( ) {
0 commit comments