11/*eslint-env node, mocha*/
22
33describe ( 'ExportToJSON' , function ( ) {
4+ const { promisify} = require ( 'util' ) ;
5+ const assert = require ( 'assert' ) . strict ;
46 var testFixture = require ( '../../globals' ) ,
57 gmeConfig = testFixture . getGmeConfig ( ) ,
6- expect = testFixture . expect ,
78 logger = testFixture . logger . fork ( 'ExportToJSON' ) ,
89 PluginCliManager = testFixture . WebGME . PluginCliManager ,
910 projectName = 'testProject' ,
@@ -13,43 +14,33 @@ describe('ExportToJSON', function () {
1314 storage ,
1415 commitHash ;
1516
16- before ( function ( done ) {
17- testFixture . clearDBAndGetGMEAuth ( gmeConfig , projectName )
18- . then ( function ( gmeAuth_ ) {
19- gmeAuth = gmeAuth_ ;
20- // This uses in memory storage. Use testFixture.getMongoStorage to persist test to database.
21- storage = testFixture . getMemoryStorage ( logger , gmeConfig , gmeAuth ) ;
22- return storage . openDatabase ( ) ;
23- } )
24- . then ( function ( ) {
25- var importParam = {
26- projectSeed : testFixture . path . join ( testFixture . SEED_DIR , 'EmptyProject.webgmex' ) ,
27- projectName : projectName ,
28- branchName : 'master' ,
29- logger : logger ,
30- gmeConfig : gmeConfig
31- } ;
17+ const manager = new PluginCliManager ( null , logger , gmeConfig ) ;
18+ manager . executePlugin = promisify ( manager . executePlugin . bind ( manager ) ) ;
3219
33- return testFixture . importProject ( storage , importParam ) ;
34- } )
35- . then ( function ( importResult ) {
36- project = importResult . project ;
37- commitHash = importResult . commitHash ;
38- return project . createBranch ( 'test' , commitHash ) ;
39- } )
40- . nodeify ( done ) ;
20+ before ( async function ( ) {
21+ gmeAuth = await testFixture . clearDBAndGetGMEAuth ( gmeConfig , projectName )
22+ storage = testFixture . getMemoryStorage ( logger , gmeConfig , gmeAuth ) ;
23+ await storage . openDatabase ( ) ;
24+ const importParam = {
25+ projectSeed : testFixture . path . join ( testFixture . SEED_DIR , 'EmptyProject.webgmex' ) ,
26+ projectName : projectName ,
27+ branchName : 'master' ,
28+ logger : logger ,
29+ gmeConfig : gmeConfig
30+ } ;
31+
32+ const importResult = await testFixture . importProject ( storage , importParam ) ;
33+ project = importResult . project ;
34+ commitHash = importResult . commitHash ;
35+ await project . createBranch ( 'test' , commitHash ) ;
4136 } ) ;
4237
43- after ( function ( done ) {
44- storage . closeDatabase ( )
45- . then ( function ( ) {
46- return gmeAuth . unload ( ) ;
47- } )
48- . nodeify ( done ) ;
38+ after ( async function ( ) {
39+ await storage . closeDatabase ( )
40+ await gmeAuth . unload ( ) ;
4941 } ) ;
5042
51- it ( 'should run plugin and update the branch' , function ( done ) {
52- var manager = new PluginCliManager ( null , logger , gmeConfig ) ,
43+ it ( 'should run plugin and update the branch' , async function ( ) {
5344 pluginConfig = {
5445 } ,
5546 context = {
@@ -59,21 +50,10 @@ describe('ExportToJSON', function () {
5950 activeNode : '/1' ,
6051 } ;
6152
62- manager . executePlugin ( pluginName , pluginConfig , context , function ( err , pluginResult ) {
63- try {
64- expect ( err ) . to . equal ( null ) ;
65- expect ( typeof pluginResult ) . to . equal ( 'object' ) ;
66- expect ( pluginResult . success ) . to . equal ( true ) ;
67- } catch ( e ) {
68- done ( e ) ;
69- return ;
70- }
71-
72- project . getBranchHash ( 'test' )
73- . then ( function ( branchHash ) {
74- expect ( branchHash ) . to . not . equal ( commitHash ) ;
75- } )
76- . nodeify ( done ) ;
77- } ) ;
53+ const pluginResult = await manager . executePlugin ( pluginName , pluginConfig , context ) ;
54+ assert . equal ( typeof pluginResult , 'object' ) ;
55+ assert ( pluginResult . success ) ;
56+ const branchHash = await project . getBranchHash ( 'test' ) ;
57+ assert . equal ( branchHash , commitHash ) ;
7858 } ) ;
7959} ) ;
0 commit comments