refactor: dummy and fyo tests use tape

This commit is contained in:
18alantom
2022-10-31 13:03:50 +05:30
parent 6806c42daf
commit 652a3c1139
4 changed files with 169 additions and 285 deletions
+18 -40
View File
@@ -1,49 +1,27 @@
import * as assert from 'assert';
import { DatabaseManager } from 'backend/database/manager';
import { assertDoesNotThrow } from 'backend/database/tests/helpers';
import { purchaseItemPartyMap } from 'dummy/helpers';
import { Fyo } from 'fyo';
import { DummyAuthDemux } from 'fyo/tests/helpers';
import 'mocha';
import { getTestDbPath } from 'tests/helpers';
import test from 'tape';
import { getTestDbPath, getTestFyo } from 'tests/helpers';
import { setupDummyInstance } from '..';
describe('dummy', function () {
const dbPath = getTestDbPath();
const dbPath = getTestDbPath();
const fyo = getTestFyo();
let fyo: Fyo;
test('setupDummyInstance', async () => {
await assertDoesNotThrow(async () => {
await setupDummyInstance(dbPath, fyo, 1, 25);
}, 'setup instance failed');
});
this.beforeAll(function () {
fyo = new Fyo({
DatabaseDemux: DatabaseManager,
AuthDemux: DummyAuthDemux,
isTest: true,
isElectron: false,
});
});
test('purchaseItemParty Existance', async (t) => {
for (const item in purchaseItemPartyMap) {
t.ok(await fyo.db.exists('Item', item), `item exists: ${item}`);
this.afterAll(async function () {
await fyo.close();
});
const party = purchaseItemPartyMap[item];
t.ok(await fyo.db.exists('Party', party), `party exists: ${party}`);
}
});
specify('setupDummyInstance', async function () {
await assertDoesNotThrow(async () => {
await setupDummyInstance(dbPath, fyo, 1, 25);
}, 'setup instance failed');
for (const item in purchaseItemPartyMap) {
assert.strictEqual(
await fyo.db.exists('Item', item),
true,
`not found ${item}`
);
const party = purchaseItemPartyMap[item];
assert.strictEqual(
await fyo.db.exists('Party', party),
true,
`not found ${party}`
);
}
}).timeout(120_000);
test.onFinish(async () => {
await fyo.close();
});