Skip to content

Commit

Permalink
Test: adds tests for the StrategyInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
bravo-kernel committed Aug 24, 2019
1 parent 9de187f commit 9ddd214
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions test/strategy-interface.test.js
@@ -0,0 +1,81 @@
const models = require('./models');
const { SchemaManager } = require('../lib');
const StrategyInterface = require('../lib/strategy-interface');

// create a dummy strategy so we can test non-implemented methods
class DummyStrategy extends StrategyInterface {}
const dummyStrategy = new DummyStrategy();

describe('StrategyInterface', function() {
// ------------------------------------------------------------------------
// make sure we are testing what we expect
// ------------------------------------------------------------------------
describe('Ensure we are testing against:', function() {
const methodCount = Object.getOwnPropertyNames(StrategyInterface.prototype).length - 1; // excluding the constructor

it(`9 interface methods`, function() {
expect(methodCount).toEqual(9);
});
});

// ------------------------------------------------------------------------
// test missing methods in the extended class
// ------------------------------------------------------------------------
describe('Ensure exceptions are thrown if child class has not implemented:', function() {
const schemaManager = new SchemaManager();

it('getOnlineSchemaUri()', function() {
expect(() => {
schemaManager.generate(models.user, dummyStrategy);
}).toThrow(Error);
});

it('getPropertySchema()', function() {
expect(() => {
schemaManager.generate(models.user, dummyStrategy);
}).toThrow(Error);
});

it('getPropertyId()', function() {
expect(() => {
schemaManager.generate(models.user, dummyStrategy);
}).toThrow(Error);
});

it('getPropertyTitle()', function() {
expect(() => {
schemaManager.generate(models.user, dummyStrategy);
}).toThrow(Error);
});

it('getPropertyDescription()', function() {
expect(() => {
schemaManager.generate(models.user, dummyStrategy);
}).toThrow(Error);
});

it('getPropertyExamples()', function() {
expect(() => {
schemaManager.generate(models.user, dummyStrategy);
}).toThrow(Error);
});

it('convertTypePropertyToAllowNull()', function() {
expect(() => {
schemaManager.generate(models.user, dummyStrategy);
}).toThrow(Error);
});

it('getPropertyForHasOneAssociation()', function() {
expect(() => {
schemaManager.generate(models.user, dummyStrategy);
}).toThrow(Error);
});

it('getPropertyForHasManyAssociation()', function() {
expect(() => {
schemaManager.generate(models.user, dummyStrategy);
}).toThrow(Error);
});
});
});

0 comments on commit 9ddd214

Please sign in to comment.