diff --git a/test/TestReferenceDataFramework.js b/test/TestReferenceDataFramework.js index e37081b..e7968cd 100644 --- a/test/TestReferenceDataFramework.js +++ b/test/TestReferenceDataFramework.js @@ -4,41 +4,24 @@ const noop = () => { }; module.exports = class TestReferenceDataFramework extends ReferenceDataFramework { #nukeCustomObjects; - #wipeCustomData; constructor(config) { super(config); this.#nukeCustomObjects = config.nukeCustomObjects || noop; - this.#wipeCustomData = config.wipeCustomData || noop; } async reset() { - await this.withTransaction(async (tx) => { - await this.#nukeCustomObjects(tx); - await this.#wipeRdfData(tx); - }) await this.init(); + await this.wipe(); } async wipe() { await this.withTransaction(async (tx) => { - await this.#wipeCustomData(tx); + await this.#nukeCustomObjects(tx); await this.#wipeRdfData(tx); }) } - async nukeCustomObjects() { - return this.withTransaction((tx) => { - return this.#nukeCustomObjects(tx); - }) - } - - async wipeRdfData() { - return this.withTransaction((tx) => { - return this.#wipeRdfData(tx); - }) - } - async #wipeRdfData(tx) { await tx.query('DELETE FROM rdf_notification'); await tx.query('DELETE FROM rdf_hook'); diff --git a/test/api.test.js b/test/api.test.js index 8ead992..9570bd8 100644 --- a/test/api.test.js +++ b/test/api.test.js @@ -19,9 +19,6 @@ const config = { await tx.query('DROP TABLE IF EXISTS vat_rate_v1'); await tx.query('DROP FUNCTION IF EXISTS get_vat_rate_v1_aggregate'); await tx.query('DROP TYPE IF EXISTS tax_rate_type'); - }, - wipeCustomData: async (tx) => { - await tx.query('DELETE FROM vat_rate_v1'); } } @@ -31,15 +28,12 @@ describe('API', () => { before(async () => { rdf = new TestReferenceDataFramework(config); - await rdf.init(); - await rdf.nukeCustomObjects(); - await rdf.wipeRdfData(); + await rdf.reset; }) beforeEach(async () => { rdf.removeAllListeners(); - await rdf.nukeCustomObjects(); - await rdf.wipeRdfData(); + await rdf.wipe(); }) afterEach(async () => { diff --git a/test/dsl.test.js b/test/dsl.test.js index 14b97dd..177c758 100644 --- a/test/dsl.test.js +++ b/test/dsl.test.js @@ -24,11 +24,6 @@ const config = { await tx.query('DROP FUNCTION IF EXISTS get_vat_rate_v2_aggregate'); await tx.query('DROP TABLE IF EXISTS cgt_rate_v1'); await tx.query('DROP FUNCTION IF EXISTS get_cgt_rate_v1_aggregate'); - }, - wipeCustomData: async (tx) => { - await tx.query('DELETE FROM vat_rate_v1'); - await tx.query('DELETE FROM vat_rate_v2'); - await tx.query('DELETE FROM cgt_rate_v1'); } } @@ -39,15 +34,12 @@ describe('DSL', () => { before(async () => { deleteMigrations(); rdf = new TestReferenceDataFramework(config); - await rdf.init(); - await rdf.nukeCustomObjects(); - await rdf.wipeRdfData(); + await rdf.reset(); }) beforeEach(async () => { deleteMigrations(); - await rdf.nukeCustomObjects(); - await rdf.wipeRdfData(); + await rdf.wipe(); }) after(async () => { diff --git a/test/notifications.test.js b/test/notifications.test.js index f22effd..178d17d 100644 --- a/test/notifications.test.js +++ b/test/notifications.test.js @@ -17,9 +17,6 @@ const config = { }, nukeCustomObjects: async (tx) => { await tx.query('DROP TABLE IF EXISTS vat_rate_v1'); - }, - wipeCustomData: async (tx) => { - await tx.query('DELETE FROM vat_rate_v1'); } } @@ -29,15 +26,12 @@ describe('Notifications', () => { before(async () => { rdf = new TestReferenceDataFramework(config); - await rdf.init(); - await rdf.nukeCustomObjects(); - await rdf.wipeRdfData(); + await rdf.reset(); }) beforeEach(async () => { rdf.removeAllListeners(); - await rdf.nukeCustomObjects(); - await rdf.wipeRdfData(); + await rdf.wipe(); }) afterEach(async () => { diff --git a/test/schema.test.js b/test/schema.test.js index 4fc7293..4388319 100644 --- a/test/schema.test.js +++ b/test/schema.test.js @@ -23,14 +23,11 @@ describe('Schema', () => { before(async () => { rdf = new TestReferenceDataFramework(config); - await rdf.init(); - await rdf.nukeCustomObjects(); - await rdf.wipeRdfData(); + await rdf.reset(); }) beforeEach(async () => { - await rdf.nukeCustomObjects(); - await rdf.wipeRdfData(); + await rdf.wipe(); }) after(async () => {