import { expect } from 'chai'; import { Container } from 'typedi'; import { OptionsMetadata } from './'; describe('Options Metadata', () => { const optionsMetadata = Container.get(OptionsMetadata); describe('App Options', () => { it('should contain default values if config files are not present', () => { expect(optionsMetadata.appOptions.bcrypt).to.be.false; expect(optionsMetadata.appOptions.templates).to.haveOwnProperty('cache'); expect(optionsMetadata.appOptions.views).to.haveOwnProperty('path'); expect(optionsMetadata.appOptions.port).to.equal(3000); expect(optionsMetadata.appOptions.args.length).to.equal(0); expect(Object.keys(optionsMetadata.appOptions.kwargs).length).to.equal(0); expect(optionsMetadata.appOptions.domain).to.equal('example.com'); expect(optionsMetadata.appOptions.extension).to.equal('js'); expect(optionsMetadata.appOptions.slack).to.be.false; }); }); describe('View Options', () => { it('should contain default values if config files are not present', () => { expect(optionsMetadata.templateOptions.enabled).to.be.true; expect(optionsMetadata.templateOptions.engine).to.equal('nunjucks'); expect(optionsMetadata.templateOptions.cache).to.be.true; expect(optionsMetadata.templateOptions.watch).to.be.true; expect(optionsMetadata.templateOptions.staticDir).to.equal('static'); expect(optionsMetadata.templateOptions.templateDir).to.equal('./templates'); }); }); describe('Keyword Arguments', () => { describe('set', () => { it('should create new keyword argument without errors', () => { expect(optionsMetadata.set('hello', 'world')).to.haveOwnProperty('hello'); }); it('should successfully persist provided kwarg', () => { expect(optionsMetadata.get('hello')).to.equal('world'); }); }); describe('remove', () => { it('should successfully set value to undefined if key exists', () => { expect((optionsMetadata.remove('hello') as any).hello).to.equal(undefined); }); }); describe('get', () => { it('should return undefined if requested kwarg does not exist', () => { expect(optionsMetadata.get('hello')).to.equal(undefined); }); }); }); });