mirror of
https://github.com/frappe/books.git
synced 2026-08-24 10:04:45 -05:00
refactor: dummy and fyo tests use tape
This commit is contained in:
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user