2022-04-11 07:15:35 +00:00
|
|
|
import * as assert from 'assert';
|
2022-04-07 13:38:17 +00:00
|
|
|
import 'mocha';
|
2022-04-18 11:29:20 +00:00
|
|
|
import models, { getRegionalModels } from 'models';
|
|
|
|
import { getSchemas } from 'schemas';
|
2022-04-19 05:59:36 +00:00
|
|
|
import { Fyo } from '..';
|
2022-04-18 06:42:56 +00:00
|
|
|
import { DatabaseManager } from '../../backend/database/manager';
|
2022-04-18 11:29:20 +00:00
|
|
|
import { DummyAuthDemux } from './helpers';
|
2022-04-07 13:38:17 +00:00
|
|
|
|
2022-04-19 05:59:36 +00:00
|
|
|
describe('Fyo Init', function () {
|
|
|
|
const fyo = new Fyo({
|
2022-04-18 11:29:20 +00:00
|
|
|
DatabaseDemux: DatabaseManager,
|
|
|
|
AuthDemux: DummyAuthDemux,
|
|
|
|
isTest: true,
|
|
|
|
isElectron: false,
|
|
|
|
});
|
2022-04-07 13:38:17 +00:00
|
|
|
|
|
|
|
specify('Init', async function () {
|
2022-04-11 07:15:35 +00:00
|
|
|
assert.strictEqual(
|
2022-04-19 05:59:36 +00:00
|
|
|
Object.keys(fyo.schemaMap).length,
|
2022-04-11 07:15:35 +00:00
|
|
|
0,
|
|
|
|
'zero schemas one'
|
|
|
|
);
|
2022-04-18 11:29:20 +00:00
|
|
|
|
2022-04-11 07:15:35 +00:00
|
|
|
assert.strictEqual(
|
2022-04-19 05:59:36 +00:00
|
|
|
Object.keys(fyo.schemaMap).length,
|
2022-04-11 07:15:35 +00:00
|
|
|
0,
|
|
|
|
'zero schemas two'
|
|
|
|
);
|
|
|
|
|
2022-04-19 05:59:36 +00:00
|
|
|
await fyo.db.createNewDatabase(':memory:', 'in');
|
|
|
|
await fyo.initializeAndRegister({}, {});
|
2022-04-11 07:15:35 +00:00
|
|
|
assert.strictEqual(
|
2022-04-19 05:59:36 +00:00
|
|
|
Object.keys(fyo.schemaMap).length > 0,
|
2022-04-11 07:15:35 +00:00
|
|
|
true,
|
|
|
|
'non zero schemas'
|
|
|
|
);
|
2022-04-19 05:59:36 +00:00
|
|
|
await fyo.db.close();
|
2022-04-07 13:38:17 +00:00
|
|
|
});
|
|
|
|
});
|
2022-04-18 11:29:20 +00:00
|
|
|
|
2022-04-19 05:59:36 +00:00
|
|
|
describe('Fyo Docs', function () {
|
2022-04-18 11:29:20 +00:00
|
|
|
const countryCode = 'in';
|
2022-04-19 05:59:36 +00:00
|
|
|
let fyo: Fyo;
|
2022-04-18 11:29:20 +00:00
|
|
|
const schemas = getSchemas(countryCode);
|
|
|
|
this.beforeEach(async function () {
|
2022-04-19 05:59:36 +00:00
|
|
|
fyo = new Fyo({
|
2022-04-18 11:29:20 +00:00
|
|
|
DatabaseDemux: DatabaseManager,
|
|
|
|
isTest: true,
|
|
|
|
isElectron: false,
|
|
|
|
});
|
|
|
|
|
|
|
|
const regionalModels = await getRegionalModels(countryCode);
|
2022-04-19 05:59:36 +00:00
|
|
|
await fyo.db.createNewDatabase(':memory:', countryCode);
|
|
|
|
await fyo.initializeAndRegister(models, regionalModels);
|
2022-04-18 11:29:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.afterEach(async function () {
|
2022-04-19 05:59:36 +00:00
|
|
|
await fyo.close();
|
2022-04-18 11:29:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
specify('temp', async function () {
|
2022-04-19 05:59:36 +00:00
|
|
|
fyo.db.schemaMap;
|
2022-04-18 11:29:20 +00:00
|
|
|
});
|
|
|
|
});
|