11'use strict' ;
22
33const Config = require ( '../lib/Config' ) ;
4- const TestUtils = require ( '../lib/TestUtils' ) ;
54const { MongoClient } = require ( 'mongodb' ) ;
65const databaseURI = 'mongodb://localhost:27017/' ;
76const request = require ( '../lib/request' ) ;
@@ -20,22 +19,33 @@ const masterKeyOptions = {
2019 json : true ,
2120} ;
2221
22+ const profileLevel = 2 ;
2323describe_only_db ( 'mongo' ) ( 'Parse.Query with comment testing' , ( ) => {
24- beforeEach ( async ( ) => {
24+ beforeAll ( async ( ) => {
2525 config = Config . get ( 'test' ) ;
2626 client = await MongoClient . connect ( databaseURI , {
2727 useNewUrlParser : true ,
2828 useUnifiedTopology : true ,
2929 } ) ;
3030 database = client . db ( 'parseServerMongoAdapterTestDatabase' ) ;
31- const level = 2 ;
32- const profiling = await database . command ( { profile : level } ) ;
33- console . log ( `profiling ${ JSON . stringify ( profiling ) } ` ) ;
31+ let profiler = await database . command ( { profile : 0 } ) ;
32+ expect ( profiler . was ) . toEqual ( 0 ) ;
33+ console . log ( `Disabling profiler : ${ profiler . was } ` ) ;
34+ profiler = await database . command ( { profile : profileLevel } ) ;
35+ profiler = await database . command ( { profile : - 1 } ) ;
36+ console . log ( `Enabling profiler : ${ profiler . was } ` ) ;
37+ profiler = await database . command ( { profile : - 1 } ) ;
38+ expect ( profiler . was ) . toEqual ( profileLevel ) ;
39+ } ) ;
40+
41+ beforeEach ( async ( ) => {
42+ const profiler = await database . command ( { profile : - 1 } ) ;
43+ expect ( profiler . was ) . toEqual ( profileLevel ) ;
3444 } ) ;
3545
36- afterEach ( async ( ) => {
46+ afterAll ( async ( ) => {
47+ await database . command ( { profile : 0 } ) ;
3748 await client . close ( ) ;
38- await TestUtils . destroyAllDataPermanently ( false ) ;
3949 } ) ;
4050
4151 it ( 'send comment with query through REST' , async ( ) => {
0 commit comments