Skip to content

Commit

Permalink
test(service): Boot config tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jezhiggins committed May 29, 2020
1 parent 245bb63 commit 1e6102a
Showing 1 changed file with 35 additions and 14 deletions.
49 changes: 35 additions & 14 deletions test/boot-service-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,59 @@ const LocalStorageService = require('../lib/components/services/localfilestorage

describe('Boot localstorage service', () => {
let localstorage
let options =
let options
const onBoot = () => { localstorage.boot(options) }

beforeEach (() => {
console.log('yes')

localstorage = new LocalStorageService()

options = {
bootedServices: {
cloudstorage: {
registerProvider: () => { }
}
}
}
})

it('localstorage registers with cloudstorage on boot', () => {
let registered = false
options.bootedServices.cloudstorage.registerProvider =
describe('good boots', () => {
it('localstorage registers with cloudstorage on boot', () => {
let registered = false
options.bootedServices.cloudstorage.registerProvider =
provider => { registered = (provider === localstorage) }

localstorage.boot(options)
expect(registered).to.be.true()
})
localstorage.boot(options)
expect(registered).to.be.true()
})

it('loudly fail if cloudstorage is not available', () => {
delete options.bootedServices.cloudstorage
const onBoot = () => { localstorage.boot(options) }
it('picks up filesystem root directory from config', () => {
localstorage.boot(options)
expect(localstorage.rootPath).to.be.a('string')
})

expect(onBoot).to.throw(/can not register/i)
it('picks up filesystem root directory from environment', () => {
localstorage.boot(options)
expect(localstorage.rootPath).to.be.a('string')
})
})

it ("loudly fail if cloudstorage isn't right", () => {
const onBoot = () => { localstorage.boot(options) }
describe('bad boots', () => {
it('loudly fail if cloudstorage is not available', () => {
delete options.bootedServices.cloudstorage

expect(onBoot).to.throw(/can not register/i)
})

it ("loudly fail if cloudstorage isn't right", () => {
delete options.bootedServices.cloudstorage.registerProvider

expect(onBoot).to.throw(/can not register/i)
})

expect(onBoot).to.throw(/can not register/i)
it ('loudly fail if path config is missing', () => {
expect(onBoot).to.throw(/missing config/i)
})
})
})

0 comments on commit 1e6102a

Please sign in to comment.