describe('#Metrics', () => { it('should return a Metrics instance with correct default options', () => { const metrics = new Metrics(); metrics.should.be.instanceof(Metrics); metrics.should.have.property('id', 'unknown'); metrics.endpoints.should.be.instanceof(Array); metrics.endpoints.should.be.empty; metrics.data.should.be.instanceof(Object); metrics.data.should.be.empty; metrics.log.should.be.instanceof(EventEmitter); }); it('should return a Metrics instance with user options', () => { const metrics = new Metrics({id: '24601', endpoints: [1, 2], data: {prisoner: 'valjean'}}); metrics.should.be.instanceof(Metrics); metrics.should.have.property('id', '24601'); metrics.data.prisoner.should.equal('valjean'); metrics.endpoints.should.have.length(2); metrics.endpoints.should.be.not.empty; metrics.data.should.be.not.empty; metrics.log.should.be.instanceof(EventEmitter); }); });
const thebest = {favs: ['britney']}; const bands = config.merge(theworst, thebest); expect(bands.favs).to.have.length(3); expect(hasher(bands.favs)).to.equal(hasher(['nickelback', 'abba', 'britney'])); }); const yourfavs = {favs: ['britney', 'nickelback']}; const ourfavs = config.merge(myfavs, yourfavs); expect(ourfavs.favs).to.have.length(3); expect(hasher(ourfavs.favs)).to.equal(hasher(['nickelback', 'abba', 'britney'])); });
expect(index.length).to.equal(1); expect(index.search("Just a multinational colonization.")).to.include(0); expect(index.search("Just an multinational colonization.")).to.include(0); expect(index.search("multinational colonization")).to.include(0); expect(index.search("tional tion")).to.have.length(0); expect(index.length).to.equal(1); expect(index.search("Just a multinational colonization.")).to.include(0); expect(index.search("Just an multinational colonization.")).to.include(0); expect(index.search("multinational colonization")).to.include(0); expect(index.search("tional tion")).to.have.length(0); }); });
setPlatform('win32'); const command = util.cliPkgTask('thing'); command.should.be.length(2); resetPlatform(); });
expect(index.length).to.equal(1); expect(index.search("today in the morning.")).to.include(0); expect(index.search("today morning")).to.include(0); expect(index.search("in the")).to.have.length(0); }); tokenize: "strict", filter: function(word){ return word.length > 3; expect(index.length).to.equal(1); expect(index.search("today in the morning.")).to.include(0); expect(index.search("today morning")).to.include(0); expect(index.search("in the")).to.have.length(0); }); });
expect(flexsearch_worker.length).to.equal(3); expect(flexsearch_worker.index).to.have.members(["@0", "@1", "@2"]); expect(result).to.have.length(2); expect(result).to.have.members([0, 1]); expect(flexsearch_worker.length).to.equal(3); expect(flexsearch_worker.index).to.have.members(["@0", "@1", "@2"]);
expect(index.length).to.equal(1); expect(index.search("Just a multinational colonization.")).to.include(0); expect(index.search("multinational colonization")).to.include(0); expect(index.search("tional tion")).to.have.length(0); }); expect(index.length).to.equal(1); expect(index.search("Just a multinational colonization.")).to.include(0); expect(index.search("multinational colonization")).to.include(0); expect(index.search("tional tion")).to.have.length(0); }); });
// end it it('Default options (no logs in routes)', async function() { console.log = logger let _event = Object.assign({},event,{ path: '/test' }) let result = await new Promise(r => api_default.run(_event,context,(e,res) => { r(res) })) console.log = consoleLog expect(result).to.deep.equal({ multiValueHeaders: { 'content-type': ['application/json'] }, statusCode: 200, body: 'done', isBase64Encoded: false }) expect(_log).to.have.length(0) })
isBase64Encoded: false }) expect(_log).to.have.length(1) expect(_log[0].level).to.equal('info')
isBase64Encoded: false }) expect(_log).to.have.length(2) expect(_log[0].level).to.equal('info') expect(_log[1].level).to.equal('access')
isBase64Encoded: false }) expect(_log).to.have.length(6) expect(_log[0].level).to.equal('debug') expect(_log[5].level).to.equal('access')
isBase64Encoded: false }) expect(_log).to.have.length(5) expect(_log[0].level).to.equal('info') expect(_log[4].level).to.equal('access')
// end it it('Disable (via level setting)', async function() { console.log = logger let _event = Object.assign({},event,{ path: '/' }) let result = await new Promise(r => api_disableLevel.run(_event,context,(e,res) => { r(res) })) console.log = consoleLog expect(result).to.deep.equal({ multiValueHeaders: { 'content-type': ['application/json'] }, statusCode: 200, body: 'done', isBase64Encoded: false }) expect(_log).to.have.length(0) })