Bury the loader fixtures with the code that uses them (#3407)

One less thing to have in the root of the project!
This commit is contained in:
Paul Melnikow
2019-05-02 12:36:00 -04:00
committed by GitHub
parent c3bc0ac96f
commit a0da978886
12 changed files with 27 additions and 25 deletions

View File

@@ -15,7 +15,7 @@
"services/**/*.tester.js",
"services/test-validators.js",
"services/tester.js",
"test-fixtures",
"core/base-service/loader-test-fixtures",
"scripts",
"coverage",
"build",

View File

@@ -1,6 +1,6 @@
'use strict'
const BaseJsonService = require('../core/base-service/base-json')
const BaseJsonService = require('../base-json')
class BadBaseService {}
class GoodService extends BaseJsonService {}

View File

@@ -1,6 +1,6 @@
'use strict'
const BaseJsonService = require('../core/base-service/base-json')
const BaseJsonService = require('../base-json')
class GoodServiceOne extends BaseJsonService {
static get category() {

View File

@@ -1,6 +1,6 @@
'use strict'
const BaseJsonService = require('../core/base-service/base-json')
const BaseJsonService = require('../base-json')
class GoodService extends BaseJsonService {
static get category() {

View File

@@ -1,6 +1,6 @@
'use strict'
const BaseJsonService = require('../core/base-service/base-json')
const BaseJsonService = require('../base-json')
class GoodServiceOne extends BaseJsonService {
static get category() {

View File

@@ -6,41 +6,43 @@ const { loadServiceClasses, InvalidService } = require('./loader')
describe('loadServiceClasses function', function() {
it('throws if module exports empty', function() {
expect(() =>
loadServiceClasses(['../../test-fixtures/empty-undefined.fixture.js'])
loadServiceClasses(['./loader-test-fixtures/empty-undefined.fixture.js'])
).to.throw(InvalidService)
expect(() =>
loadServiceClasses(['../../test-fixtures/empty-array.fixture.js'])
loadServiceClasses(['./loader-test-fixtures/empty-array.fixture.js'])
).to.throw()
expect(() =>
loadServiceClasses(['../../test-fixtures/empty-object.fixture.js'])
loadServiceClasses(['./loader-test-fixtures/empty-object.fixture.js'])
).to.throw(InvalidService)
expect(() =>
loadServiceClasses(['../../test-fixtures/empty-no-export.fixture.js'])
loadServiceClasses(['./loader-test-fixtures/empty-no-export.fixture.js'])
).to.throw(InvalidService)
expect(() =>
loadServiceClasses([
'../../test-fixtures/valid-array.fixture.js',
'../../test-fixtures/valid-class.fixture.js',
'../../test-fixtures/empty-array.fixture.js',
'./loader-test-fixtures/valid-array.fixture.js',
'./loader-test-fixtures/valid-class.fixture.js',
'./loader-test-fixtures/empty-array.fixture.js',
])
).to.throw(InvalidService)
})
it('throws if module exports invalid', function() {
expect(() =>
loadServiceClasses(['../../test-fixtures/invalid-no-base.fixture.js'])
).to.throw(InvalidService)
expect(() =>
loadServiceClasses(['../../test-fixtures/invalid-wrong-base.fixture.js'])
).to.throw(InvalidService)
expect(() =>
loadServiceClasses(['../../test-fixtures/invalid-mixed.fixture.js'])
loadServiceClasses(['./loader-test-fixtures/invalid-no-base.fixture.js'])
).to.throw(InvalidService)
expect(() =>
loadServiceClasses([
'../../test-fixtures/valid-array.fixture.js',
'../../test-fixtures/valid-class.fixture.js',
'../../test-fixtures/invalid-no-base.fixture.js',
'./loader-test-fixtures/invalid-wrong-base.fixture.js',
])
).to.throw(InvalidService)
expect(() =>
loadServiceClasses(['./loader-test-fixtures/invalid-mixed.fixture.js'])
).to.throw(InvalidService)
expect(() =>
loadServiceClasses([
'./loader-test-fixtures/valid-array.fixture.js',
'./loader-test-fixtures/valid-class.fixture.js',
'./loader-test-fixtures/invalid-no-base.fixture.js',
])
).to.throw(InvalidService)
})
@@ -48,9 +50,9 @@ describe('loadServiceClasses function', function() {
it('registers services if module exports valid service classes', function() {
expect(
loadServiceClasses([
'../../test-fixtures/valid-array.fixture.js',
'../../test-fixtures/valid-object.fixture.js',
'../../test-fixtures/valid-class.fixture.js',
'./loader-test-fixtures/valid-array.fixture.js',
'./loader-test-fixtures/valid-object.fixture.js',
'./loader-test-fixtures/valid-class.fixture.js',
])
).to.have.length(5)
})