2022-04-21 18:38:36 +05:30
|
|
|
import { getRegionalModels, models } from 'models';
|
2022-04-18 16:59:20 +05:30
|
|
|
import { getSchemas } from 'schemas';
|
2022-10-31 13:03:50 +05:30
|
|
|
import test from 'tape';
|
|
|
|
import { getTestFyo } from 'tests/helpers';
|
2022-04-07 19:08:17 +05:30
|
|
|
|
2022-10-31 13:03:50 +05:30
|
|
|
test('Fyo Init', async (t) => {
|
|
|
|
const fyo = getTestFyo();
|
|
|
|
t.equal(Object.keys(fyo.schemaMap).length, 0, 'zero schemas');
|
2022-04-07 19:08:17 +05:30
|
|
|
|
2022-10-31 13:03:50 +05:30
|
|
|
await fyo.db.createNewDatabase(':memory:', 'in');
|
|
|
|
await fyo.initializeAndRegister({}, {});
|
2022-04-18 16:59:20 +05:30
|
|
|
|
2022-10-31 13:03:50 +05:30
|
|
|
t.equal(Object.keys(fyo.schemaMap).length > 0, true, 'non zero schemas');
|
|
|
|
await fyo.close();
|
2022-04-07 19:08:17 +05:30
|
|
|
});
|
2022-04-18 16:59:20 +05:30
|
|
|
|
2022-10-31 13:03:50 +05:30
|
|
|
test('Fyo Docs', async (t) => {
|
2022-04-18 16:59:20 +05:30
|
|
|
const countryCode = 'in';
|
2022-10-31 13:03:50 +05:30
|
|
|
const fyo = getTestFyo();
|
2023-08-03 13:18:14 +05:30
|
|
|
const schemaMap = getSchemas(countryCode, []);
|
2022-10-31 13:03:50 +05:30
|
|
|
const regionalModels = await getRegionalModels(countryCode);
|
|
|
|
await fyo.db.createNewDatabase(':memory:', countryCode);
|
|
|
|
await fyo.initializeAndRegister(models, regionalModels);
|
|
|
|
|
|
|
|
for (const schemaName in schemaMap) {
|
|
|
|
const schema = schemaMap[schemaName];
|
|
|
|
if (schema?.isSingle) {
|
|
|
|
continue;
|
|
|
|
}
|
2022-04-18 16:59:20 +05:30
|
|
|
|
2022-10-31 13:03:50 +05:30
|
|
|
const doc = fyo.doc.getNewDoc(schemaName);
|
|
|
|
t.equal(doc.schemaName, schemaName, `equal schemaNames: ${schemaName}`);
|
|
|
|
}
|
2022-04-20 12:08:47 +05:30
|
|
|
|
2022-10-31 13:03:50 +05:30
|
|
|
await fyo.close();
|
2022-04-18 16:59:20 +05:30
|
|
|
});
|