Просмотр исходного кода

fix test with current state of the branch

mizozobu 6 лет назад
Родитель
Сommit
1f3a013cb4
2 измененных файлов с 9 добавлено и 17 удалено
  1. 5 5
      src/server/crowi/index.js
  2. 4 12
      src/test/models/config.test.js

+ 5 - 5
src/server/crowi/index.js

@@ -118,7 +118,7 @@ Crowi.prototype.initForTest = async function() {
     // this.setUpSlacklNotification(),
   ]);
 
-  // await Promise.all([
+  await Promise.all([
   //   this.scanRuntimeVersions(),
   //   this.setupPassport(),
   //   this.setupSearcher(),
@@ -127,10 +127,10 @@ Crowi.prototype.initForTest = async function() {
   //   this.setupCsrf(),
   //   this.setUpGlobalNotification(),
   //   this.setUpFileUpload(),
-  //   this.setUpAcl(),
+    this.setUpAcl(),
   //   this.setUpCustomize(),
   //   this.setUpRestQiitaAPI(),
-  // ]);
+  ]);
 };
 
 Crowi.prototype.isPageId = function(pageId) {
@@ -474,7 +474,7 @@ Crowi.prototype.setUpXss = function() {
 /**
  * setup AclService
  */
-Crowi.prototype.setUpAcl = function() {
+Crowi.prototype.setUpAcl = async function() {
   const AclService = require('../service/acl');
   if (this.aclService == null) {
     this.aclService = new AclService(this.configManager);
@@ -496,7 +496,7 @@ Crowi.prototype.setUpCustomize = function() {
 /**
  * setup AppService
  */
-Crowi.prototype.setUpApp = function() {
+Crowi.prototype.setUpApp = async function() {
   const AppService = require('../service/app');
   if (this.appService == null) {
     this.appService = new AppService(this.configManager);

+ 4 - 12
src/test/models/config.test.js

@@ -1,27 +1,19 @@
-const mongoose = require('mongoose');
-
 const { getInstance } = require('../setup-crowi');
 
 describe('Config model test', () => {
   // eslint-disable-next-line no-unused-vars
   let crowi;
-  let Config;
 
   beforeAll(async(done) => {
     crowi = await getInstance();
     done();
   });
 
-  beforeEach(async(done) => {
-    Config = mongoose.model('Config');
-    done();
-  });
-
   describe('.CONSTANTS', () => {
-    test('Config has constants', async() => {
-      expect(Config.SECURITY_REGISTRATION_MODE_OPEN).toBe('Open');
-      expect(Config.SECURITY_REGISTRATION_MODE_RESTRICTED).toBe('Resricted');
-      expect(Config.SECURITY_REGISTRATION_MODE_CLOSED).toBe('Closed');
+    test('AclService has constants', async() => {
+      expect(crowi.aclService.labels.SECURITY_REGISTRATION_MODE_OPEN).toBe('Open');
+      expect(crowi.aclService.labels.SECURITY_REGISTRATION_MODE_RESTRICTED).toBe('Resricted');
+      expect(crowi.aclService.labels.SECURITY_REGISTRATION_MODE_CLOSED).toBe('Closed');
     });
   });