2
0
mirror of https://github.com/frappe/books.git synced 2024-11-15 01:44:04 +00:00
books/fyo/tests/testFyo.spec.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
1.1 KiB
TypeScript
Raw Normal View History

import { getRegionalModels, models } from 'models';
import { getSchemas } from 'schemas';
2022-10-31 07:33:50 +00:00
import test from 'tape';
import { getTestFyo } from 'tests/helpers';
2022-10-31 07:33:50 +00:00
test('Fyo Init', async (t) => {
const fyo = getTestFyo();
t.equal(Object.keys(fyo.schemaMap).length, 0, 'zero schemas');
2022-10-31 07:33:50 +00:00
await fyo.db.createNewDatabase(':memory:', 'in');
await fyo.initializeAndRegister({}, {});
2022-10-31 07:33:50 +00:00
t.equal(Object.keys(fyo.schemaMap).length > 0, true, 'non zero schemas');
await fyo.close();
});
2022-10-31 07:33:50 +00:00
test('Fyo Docs', async (t) => {
const countryCode = 'in';
2022-10-31 07:33:50 +00:00
const fyo = getTestFyo();
const schemaMap = getSchemas(countryCode, []);
2022-10-31 07:33:50 +00:00
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-10-31 07:33:50 +00:00
const doc = fyo.doc.getNewDoc(schemaName);
t.equal(doc.schemaName, schemaName, `equal schemaNames: ${schemaName}`);
}
2022-04-20 06:38:47 +00:00
2022-10-31 07:33:50 +00:00
await fyo.close();
});