|
@@ -1,26 +1,23 @@
|
|
|
-const helpers = require('@commons/util/helpers');
|
|
|
|
|
|
|
+const { getInstance } = require('../setup-crowi');
|
|
|
|
|
|
|
|
describe('Test for Crowi application context', () => {
|
|
describe('Test for Crowi application context', () => {
|
|
|
|
|
|
|
|
- const Crowi = require('@server/crowi');
|
|
|
|
|
-
|
|
|
|
|
describe('construction', () => {
|
|
describe('construction', () => {
|
|
|
- test('initialize crowi context', () => {
|
|
|
|
|
- const crowi = new Crowi(helpers.root());
|
|
|
|
|
- expect(crowi).toBeInstanceOf(Crowi);
|
|
|
|
|
|
|
+ test('initialize crowi context', async() => {
|
|
|
|
|
+ const crowi = await getInstance();
|
|
|
expect(crowi.version).toBe(require('@root/package.json').version);
|
|
expect(crowi.version).toBe(require('@root/package.json').version);
|
|
|
expect(typeof crowi.env).toBe('object');
|
|
expect(typeof crowi.env).toBe('object');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- test('config getter, setter', () => {
|
|
|
|
|
- const crowi = new Crowi(helpers.root());
|
|
|
|
|
|
|
+ test('config getter, setter', async() => {
|
|
|
|
|
+ const crowi = await getInstance();
|
|
|
expect(crowi.getConfig()).toEqual({});
|
|
expect(crowi.getConfig()).toEqual({});
|
|
|
crowi.setConfig({ test: 1 });
|
|
crowi.setConfig({ test: 1 });
|
|
|
expect(crowi.getConfig()).toEqual({ test: 1 });
|
|
expect(crowi.getConfig()).toEqual({ test: 1 });
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- test('model getter, setter', () => {
|
|
|
|
|
- const crowi = new Crowi(helpers.root());
|
|
|
|
|
|
|
+ test('model getter, setter', async() => {
|
|
|
|
|
+ const crowi = await getInstance();
|
|
|
// set
|
|
// set
|
|
|
crowi.model('hoge', { fuga: 1 });
|
|
crowi.model('hoge', { fuga: 1 });
|
|
|
expect(crowi.model('hoge')).toEqual({ fuga: 1 });
|
|
expect(crowi.model('hoge')).toEqual({ fuga: 1 });
|