@@ -9,19 +9,19 @@ describe('pouchdb-find: test.kitchen-sink-2.js', function () {
99 // tests that don't destroy/recreate the database for each test,
1010 // because that makes them take a long time
1111
12- function humanizeNum ( i ) {
13- var res = ( i + 1 ) . toString ( ) ;
12+ const humanizeNum = ( i ) => {
13+ let res = ( i + 1 ) . toString ( ) ;
1414 while ( res . length < 3 ) {
1515 res = '0' + res ;
1616 }
1717 return res ;
18- }
18+ } ;
1919
20- var dbName = testUtils . adapterUrl ( testUtils . adapterType ( ) , 'testdb' ) ;
20+ const dbName = testUtils . adapterUrl ( testUtils . adapterType ( ) , 'testdb' ) ;
2121
2222 this . timeout ( 100000 ) ;
2323
24- var context = { } ;
24+ const context = { } ;
2525
2626 before ( function ( ) {
2727 this . timeout ( 60000 ) ;
@@ -40,10 +40,10 @@ describe('pouchdb-find: test.kitchen-sink-2.js', function () {
4040 { name : 'samus' , rank : 12 , _id : 'samus' , series : 'metroid' , debut : 1986 } ,
4141 { name : 'yoshi' , _id : 'yoshi' , rank : 6 , series : 'mario' , debut : 1990 } ,
4242 { name : 'kirby' , _id : 'kirby' , series : 'kirby' , rank : 2 , debut : 1992 }
43- ] ) . then ( function ( ) {
43+ ] ) . then ( ( ) => {
4444 // This could be done by Promise.all, but for now that breaks IDBNext.
4545 // Promise.all index creation is tested explicitly in test.ddoc.js
46- var indexes = [
46+ const indexes = [
4747 { index : { fields : [ 'rank' ] } } ,
4848 { index : { fields : [ 'series' ] } } ,
4949 { index : { fields : [ 'debut' ] } } ,
@@ -54,8 +54,8 @@ describe('pouchdb-find: test.kitchen-sink-2.js', function () {
5454 { index : { fields : [ 'rank' , 'debut' ] } } ,
5555 ] ;
5656
57- return indexes . reduce ( function ( p , index ) {
58- return p . then ( function ( ) { return context . db . createIndex ( index ) ; } ) ;
57+ return indexes . reduce ( ( p , index ) => {
58+ return p . then ( ( ) => context . db . createIndex ( index ) ) ;
5959 } , Promise . resolve ( ) ) ;
6060 } ) ;
6161 } ) ;
@@ -68,19 +68,17 @@ describe('pouchdb-find: test.kitchen-sink-2.js', function () {
6868 // var configs = // whatever python spit out
6969 // var tests = []
7070 // configs.forEach(function (config) {db.find(config).then(function (res) {return {res: {docs: res.docs.map(function (doc) {return doc._id;})}}}, function (err){return {err: err}}).then(function (res){tests.push({input: config, output: res})}) })
71- var testConfigs = [ { "input" :{ "selector" :{ "$and" :[ { "series" :{ "$ne" :"kirby" } } , { "series" :{ "$ne" :"pokemon" } } , { "_id" :{ "$gt" :"mario" } } , { "debut" :{ "$lte" :1993 } } ] } } , "output" :{ "res" :{ "docs" :[ "samus" , "yoshi" ] } } } , { "input" :{ "selector" :{ "_id" :{ "$gte" :"link" } } } , "output" :{ "res" :{ "docs" :[ "link" , "luigi" , "mario" , "ness" , "pikachu" , "puff" , "samus" , "yoshi" ] } } } , { "input" :{ "selector" :{ "_id" :{ "$lt" :"samus" , "$gt" : "a" } } } , "output" :{ "res" :{ "docs" :[ "dk" , "falcon" , "fox" , "kirby" , "link" , "luigi" , "mario" , "ness" , "pikachu" , "puff" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "_id" :{ "$eq" :"pikach" } } , { "name" :{ "$gte" :"link" } } , { "rank" :{ "$ne" :8 } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "rank" :{ "$lt" :1 } } , { "_id" :{ "$lt" :"fox" } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "name" :{ "$ne" :"jigglypuff" } } , { "_id" :{ "$lt" :"puff" } } , { "rank" :{ "$gte" :4 } } , { "_id" :{ "$gt" :"pikach" } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "_id" :{ "$lte" :"dk" } } , { "series" :{ "$lt" :"mario" } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "series" :{ "$lt" :"star fox" } } , { "_id" :{ "$gte" :"ness" } } ] } } , "output" :{ "res" :{ "docs" :[ "ness" , "pikachu" , "puff" , "samus" , "yoshi" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "_id" :{ "$gt" :"samus" } } , { "name" :{ "$gt" :"fox" } } ] } } , "output" :{ "res" :{ "docs" :[ "yoshi" ] } } } , { "input" :{ "sort" :[ "_id" ] , "selector" :{ "$and" :[ { "rank" :{ "$ne" :4 } } , { "rank" :{ "$gte" :9 } } , { "_id" :{ "$gt" :"ness" } } , { "_id" :{ "$ne" :"ness" } } ] } } , "output" :{ "res" :{ "docs" :[ "samus" ] } } } , { "input" :{ "sort" :[ "_id" ] , "selector" :{ "$and" :[ { "name" :{ "$gt" :"yoshi" } } , { "_id" :{ "$lte" :"puff" } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "series" :{ "$gte" :"kirby" } } , { "_id" :{ "$lte" :"dk" } } ] } } , "output" :{ "res" :{ "docs" :[ "dk" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "series" :{ "$gt" :"mario" } } , { "_id" :{ "$lt" :"mario" } } , { "name" :{ "$ne" :"link" } } ] } } , "output" :{ "res" :{ "docs" :[ "fox" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "name" :{ "$eq" :"fox" } } , { "_id" :{ "$lte" :"pikach" } } ] } } , "output" :{ "res" :{ "docs" :[ "fox" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "rank" :{ "$lt" :9 } } , { "_id" :{ "$lte" :"puff" } } ] } } , "output" :{ "res" :{ "docs" :[ "dk" , "falcon" , "fox" , "kirby" , "mario" , "pikachu" , "puff" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "name" :{ "$eq" :"ness" } } , { "_id" :{ "$lte" :"luigi" } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "name" :{ "$lte" :"mario" } } , { "_id" :{ "$lt" :"mario" } } , { "debut" :{ "$eq" :1990 } } ] } } , "output" :{ "res" :{ "docs" :[ "falcon" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "debut" :{ "$lte" :1994 } } , { "_id" :{ "$lte" :"link" } } , { "_id" :{ "$lte" :"pikach" } } , { "rank" :{ "$gt" :4 } } ] } } , "output" :{ "res" :{ "docs" :[ "dk" , "link" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "name" :{ "$lt" :"yoshi" } } , { "_id" :{ "$eq" :"falcon" } } , { "rank" :{ "$ne" :2 } } ] } } , "output" :{ "res" :{ "docs" :[ "falcon" ] } } } , { "input" :{ "sort" :[ "_id" ] , "selector" :{ "_id" :{ "$lt" :"falcon" , "$gt" : "a" } } } , "output" :{ "res" :{ "docs" :[ "dk" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "rank" :{ "$gte" :5 } } , { "_id" :{ "$lt" :"link" } } , { "series" :{ "$ne" :"mario" } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "rank" :{ "$gt" :10 } } , { "_id" :{ "$lt" :"luigi" } } , { "series" :{ "$gte" :"mario" } } , { "debut" :{ "$lt" :1992 } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "name" :{ "$gt" :"samus" } } , { "_id" :{ "$gte" :"kirby" } } , { "series" :{ "$gte" :"pokemon" } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "series" :{ "$lt" :"f-zero" } } , { "_id" :{ "$lt" :"pikach" } } ] } } , "output" :{ "res" :{ "docs" :[ "ness" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "rank" :{ "$lt" :6 } } , { "_id" :{ "$eq" :"kirby" } } , { "name" :{ "$eq" :"fox" } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "name" :{ "$lt" :"luigi" } } , { "name" :{ "$lt" :"jigglypuff" } } , { "_id" :{ "$gt" :"samus" } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "series" :{ "$lte" :"mario" } } , { "_id" :{ "$gte" :"kirby" } } , { "_id" :{ "$lt" :"puff" } } ] } } , "output" :{ "res" :{ "docs" :[ "kirby" , "luigi" , "mario" , "ness" ] } } } , { "input" :{ "sort" :[ "_id" ] , "selector" :{ "$and" :[ { "series" :{ "$eq" :"pokemon" } } , { "_id" :{ "$gte" :"samus" } } , { "rank" :{ "$ne" :4 } } , { "debut" :{ "$ne" :1990 } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "series" :{ "$gt" :"mario" } } , { "_id" :{ "$lt" :"mario" } } ] } } , "output" :{ "res" :{ "docs" :[ "fox" , "link" ] } } } , { "input" :{ "sort" :[ "_id" ] , "selector" :{ "$and" :[ { "_id" :{ "$lt" :"fox" } } , { "debut" :{ "$ne" :1993 } } , { "name" :{ "$lte" :"luigi" } } ] } } , "output" :{ "res" :{ "docs" :[ "dk" , "falcon" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "_id" :{ "$lt" :"samus" } } , { "debut" :{ "$ne" :1986 } } , { "debut" :{ "$lte" :1983 } } ] } } , "output" :{ "res" :{ "docs" :[ "dk" , "luigi" , "mario" ] } } } , { "input" :{ "selector" :{ "_id" :{ "$gt" :"fox" } } } , "output" :{ "res" :{ "docs" :[ "kirby" , "link" , "luigi" , "mario" , "ness" , "pikachu" , "puff" , "samus" , "yoshi" ] } } } ] ;
71+ const testConfigs = [ { "input" :{ "selector" :{ "$and" :[ { "series" :{ "$ne" :"kirby" } } , { "series" :{ "$ne" :"pokemon" } } , { "_id" :{ "$gt" :"mario" } } , { "debut" :{ "$lte" :1993 } } ] } } , "output" :{ "res" :{ "docs" :[ "samus" , "yoshi" ] } } } , { "input" :{ "selector" :{ "_id" :{ "$gte" :"link" } } } , "output" :{ "res" :{ "docs" :[ "link" , "luigi" , "mario" , "ness" , "pikachu" , "puff" , "samus" , "yoshi" ] } } } , { "input" :{ "selector" :{ "_id" :{ "$lt" :"samus" , "$gt" : "a" } } } , "output" :{ "res" :{ "docs" :[ "dk" , "falcon" , "fox" , "kirby" , "link" , "luigi" , "mario" , "ness" , "pikachu" , "puff" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "_id" :{ "$eq" :"pikach" } } , { "name" :{ "$gte" :"link" } } , { "rank" :{ "$ne" :8 } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "rank" :{ "$lt" :1 } } , { "_id" :{ "$lt" :"fox" } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "name" :{ "$ne" :"jigglypuff" } } , { "_id" :{ "$lt" :"puff" } } , { "rank" :{ "$gte" :4 } } , { "_id" :{ "$gt" :"pikach" } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "_id" :{ "$lte" :"dk" } } , { "series" :{ "$lt" :"mario" } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "series" :{ "$lt" :"star fox" } } , { "_id" :{ "$gte" :"ness" } } ] } } , "output" :{ "res" :{ "docs" :[ "ness" , "pikachu" , "puff" , "samus" , "yoshi" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "_id" :{ "$gt" :"samus" } } , { "name" :{ "$gt" :"fox" } } ] } } , "output" :{ "res" :{ "docs" :[ "yoshi" ] } } } , { "input" :{ "sort" :[ "_id" ] , "selector" :{ "$and" :[ { "rank" :{ "$ne" :4 } } , { "rank" :{ "$gte" :9 } } , { "_id" :{ "$gt" :"ness" } } , { "_id" :{ "$ne" :"ness" } } ] } } , "output" :{ "res" :{ "docs" :[ "samus" ] } } } , { "input" :{ "sort" :[ "_id" ] , "selector" :{ "$and" :[ { "name" :{ "$gt" :"yoshi" } } , { "_id" :{ "$lte" :"puff" } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "series" :{ "$gte" :"kirby" } } , { "_id" :{ "$lte" :"dk" } } ] } } , "output" :{ "res" :{ "docs" :[ "dk" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "series" :{ "$gt" :"mario" } } , { "_id" :{ "$lt" :"mario" } } , { "name" :{ "$ne" :"link" } } ] } } , "output" :{ "res" :{ "docs" :[ "fox" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "name" :{ "$eq" :"fox" } } , { "_id" :{ "$lte" :"pikach" } } ] } } , "output" :{ "res" :{ "docs" :[ "fox" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "rank" :{ "$lt" :9 } } , { "_id" :{ "$lte" :"puff" } } ] } } , "output" :{ "res" :{ "docs" :[ "dk" , "falcon" , "fox" , "kirby" , "mario" , "pikachu" , "puff" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "name" :{ "$eq" :"ness" } } , { "_id" :{ "$lte" :"luigi" } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "name" :{ "$lte" :"mario" } } , { "_id" :{ "$lt" :"mario" } } , { "debut" :{ "$eq" :1990 } } ] } } , "output" :{ "res" :{ "docs" :[ "falcon" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "debut" :{ "$lte" :1994 } } , { "_id" :{ "$lte" :"link" } } , { "_id" :{ "$lte" :"pikach" } } , { "rank" :{ "$gt" :4 } } ] } } , "output" :{ "res" :{ "docs" :[ "dk" , "link" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "name" :{ "$lt" :"yoshi" } } , { "_id" :{ "$eq" :"falcon" } } , { "rank" :{ "$ne" :2 } } ] } } , "output" :{ "res" :{ "docs" :[ "falcon" ] } } } , { "input" :{ "sort" :[ "_id" ] , "selector" :{ "_id" :{ "$lt" :"falcon" , "$gt" : "a" } } } , "output" :{ "res" :{ "docs" :[ "dk" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "rank" :{ "$gte" :5 } } , { "_id" :{ "$lt" :"link" } } , { "series" :{ "$ne" :"mario" } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "rank" :{ "$gt" :10 } } , { "_id" :{ "$lt" :"luigi" } } , { "series" :{ "$gte" :"mario" } } , { "debut" :{ "$lt" :1992 } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "name" :{ "$gt" :"samus" } } , { "_id" :{ "$gte" :"kirby" } } , { "series" :{ "$gte" :"pokemon" } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "series" :{ "$lt" :"f-zero" } } , { "_id" :{ "$lt" :"pikach" } } ] } } , "output" :{ "res" :{ "docs" :[ "ness" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "rank" :{ "$lt" :6 } } , { "_id" :{ "$eq" :"kirby" } } , { "name" :{ "$eq" :"fox" } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "name" :{ "$lt" :"luigi" } } , { "name" :{ "$lt" :"jigglypuff" } } , { "_id" :{ "$gt" :"samus" } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "series" :{ "$lte" :"mario" } } , { "_id" :{ "$gte" :"kirby" } } , { "_id" :{ "$lt" :"puff" } } ] } } , "output" :{ "res" :{ "docs" :[ "kirby" , "luigi" , "mario" , "ness" ] } } } , { "input" :{ "sort" :[ "_id" ] , "selector" :{ "$and" :[ { "series" :{ "$eq" :"pokemon" } } , { "_id" :{ "$gte" :"samus" } } , { "rank" :{ "$ne" :4 } } , { "debut" :{ "$ne" :1990 } } ] } } , "output" :{ "res" :{ "docs" :[ ] } } } , { "input" :{ "selector" :{ "$and" :[ { "series" :{ "$gt" :"mario" } } , { "_id" :{ "$lt" :"mario" } } ] } } , "output" :{ "res" :{ "docs" :[ "fox" , "link" ] } } } , { "input" :{ "sort" :[ "_id" ] , "selector" :{ "$and" :[ { "_id" :{ "$lt" :"fox" } } , { "debut" :{ "$ne" :1993 } } , { "name" :{ "$lte" :"luigi" } } ] } } , "output" :{ "res" :{ "docs" :[ "dk" , "falcon" ] } } } , { "input" :{ "selector" :{ "$and" :[ { "_id" :{ "$lt" :"samus" } } , { "debut" :{ "$ne" :1986 } } , { "debut" :{ "$lte" :1983 } } ] } } , "output" :{ "res" :{ "docs" :[ "dk" , "luigi" , "mario" ] } } } , { "input" :{ "selector" :{ "_id" :{ "$gt" :"fox" } } } , "output" :{ "res" :{ "docs" :[ "kirby" , "link" , "luigi" , "mario" , "ness" , "pikachu" , "puff" , "samus" , "yoshi" ] } } } ] ;
7272
73- testConfigs . forEach ( function ( testConfig , i ) {
73+ testConfigs . forEach ( ( testConfig , i ) => {
7474
75- function kitchenSinkTest ( ) {
76- var db = context . db ;
77- var query = testConfig . input ;
75+ const kitchenSinkTest = ( ) => {
76+ const db = context . db ;
77+ const query = testConfig . input ;
7878 query . fields = [ '_id' ] ;
79- return db . find ( query ) . then ( function ( res ) {
79+ return db . find ( query ) . then ( ( res ) => {
8080 if ( testConfig . output . res ) {
81- var ids = res . docs . map ( function ( x ) {
82- return x . _id ;
83- } ) ;
81+ const ids = res . docs . map ( ( x ) => x . _id ) ;
8482 if ( ! testConfig . input . sort ) {
8583 // no guaranteed sorting, so ignore order
8684 ids . sort ( ) ;
@@ -92,16 +90,16 @@ describe('pouchdb-find: test.kitchen-sink-2.js', function () {
9290 res . warning . should . equal ( 'no matching index found, create an ' +
9391 'index to optimize query time' ) ;
9492 }
95- } , function ( err ) {
93+ } , ( err ) => {
9694 if ( testConfig . output . res ) {
9795 should . not . exist ( err , 'should not have thrown an error' ) ;
9896 } else {
9997 should . exist ( err ) ;
10098 }
10199 } ) ;
102- }
100+ } ;
103101
104- var testName = ' kitchen sink 2 test #' + humanizeNum ( i ) ;
102+ const testName = ` kitchen sink 2 test #${ humanizeNum ( i ) } ` ;
105103
106104 it ( testName , kitchenSinkTest ) ;
107105
0 commit comments