2
0
mirror of https://github.com/frappe/books.git synced 2024-11-14 09:24:04 +00:00
books/fyo/tests/testFyo.spec.ts
18alantom bf10927be9 feat: enable custom fields
- fix date issue in setup test
2023-08-03 13:18:14 +05:30

37 lines
1.1 KiB
TypeScript

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