From 6d963927c50ea0977f9c0c8772fa38940d36ba3a Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Thu, 5 Jan 2023 18:08:08 +0000 Subject: [PATCH] Add a test to ensure 'not implemented' is tested --- test/models/legacy-base.model.test.js | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/models/legacy-base.model.test.js diff --git a/test/models/legacy-base.model.test.js b/test/models/legacy-base.model.test.js new file mode 100644 index 0000000000..7125a00d94 --- /dev/null +++ b/test/models/legacy-base.model.test.js @@ -0,0 +1,35 @@ +'use strict' + +// Test framework dependencies +const Lab = require('@hapi/lab') +const Code = require('@hapi/code') + +const { describe, it } = exports.lab = Lab.script() +const { expect } = Code + +// Thing under test +const LegacyBaseModel = require('../../app/models/legacy-base.model.js') + +describe('Legacy Base model', () => { + describe('.schema()', () => { + describe('when the getter is not overridden', () => { + class BadModel extends LegacyBaseModel {} + + it('throws an error when called', () => { + expect(() => BadModel.query()).to.throw() + }) + }) + + describe('when the getter is overridden', () => { + class GoodModel extends LegacyBaseModel { + static get schema () { + return 'water' + } + } + + it('does not throw an error when called', () => { + expect(() => GoodModel.query()).not.to.throw() + }) + }) + }) +})