describe('a customer', () => { it('should place an order', done => { let menu = ['pizza', 'wings', 'hotdog'] let customer = new Customer() customer.placeOrder(menu, (error, order) => { expect(order).to.be.oneOf(menu) done() }) }) })
export default function () { this.Then(/^there is a new weather card with "([^"]*)" title in the result list$/, (expectedText) => { const cardsTitles = getWeatherCardsTitles() expect(expectedText).to.be.oneOf(cardsTitles) }) }
it('reconnect: should skip re-login and re-connect WS when there is a CSDS failure', (done) => { // Let: requestCSDSStub.yieldsAsync(new Error('cannot fetch CSDS domains')); externalServices.login.yieldsAsync(null, {bearer: 'im encrypted', config: {userId: 'imauser'}}); externalServices.refreshSession.yieldsAsync(null, {}); const agent = new Agent({ accountId: 'account', username: 'me', password: 'password' }); // If: agent.reconnect(false); // Then: agent.on('error', (err, context) => { if (context && context.location) { expect(context.location).to.be.oneOf(['Connect#CSDS', 'Reconnect#CSDS']); } }); done(); });
it('reconnect: should re-login and re-connect WS when flag is false', (done) => { // Let: requestCSDSStub.yieldsAsync(null, {}, csdsResponse); externalServices.login.yieldsAsync(null, {bearer: 'im encrypted', config: {userId: 'imauser'}}); externalServices.refreshSession.yieldsAsync(null, {}); const agent = new Agent({ accountId: 'account', username: 'me', password: 'password' }); // If: agent.on('connected', () => { agent.reconnect(false); done(); }); // Then: agent.on('success', (context) => { if (context && context.location) { expect(context.location).to.be.oneOf(['Connect#CSDS', 'Connect#Login', 'Reconnect#CSDS', 'Reconnect#Relogin#WS']); } }); });
describe('GET /user/account/unlink/mock_provider', () => { it('should return 302', done => { user .get('/user/account/unlink/mock_provider') .expect(302, done) }) it('should not find the mock_provider', done => { User.findOne({ email: USER_INFO.email }, (err, user) => { if (err) return done(err); var providers = _.map(user.providers, 'name'); expect('mock_provider').to.not.be.oneOf(providers); done(); }); }); });
it('should stream a cursor', async () => { const cursor = db.a.findAsCursor(); let runs = 0 const loop = () => { let doc; while ((doc = cursor.read()) !== null) { expect(doc.name).to.be.oneOf(['Squirtle', 'Starmie', 'Charmander', 'Lapras', 'bulbasaur']); expect(doc).to.be.a('object'); runs++ } cursor.once('readable', loop); } loop(); return new Promise((resolve) => { cursor.on('end', function () { expect(runs).to.equal(5); resolve(); }); }); });
expect(firstPort = session.inspect().port).to.be.oneOf(endpoints.map(e => e.port)); return session.close(); }) }) .then(session => { expect(secondPort = session.inspect().port).to.be.oneOf(endpoints.filter(e => e.port !== firstPort).map(e => e.port)); return session.close(); }) }) .then(session => { expect(thirdPort = session.inspect().port).to.be.oneOf(endpoints.filter(e => e.port !== secondPort).map(e => e.port)); return session.close(); })
describe('#unit', () => { it('should be acceptable', () => { expect(geoData.defaults.unit).to.be.oneOf([ 'meter', 'km',
expect(pin).to.be.oneOf([RESET_PIN, BUSY_PIN, DC_PIN]); if (pin === RESET_PIN) { return pinReset;
it('Should returns transaction status', async () => { let { state } = await instance.getTransactionStatus(transactionId, oldUser) expect(state).to.be.a('string') expect(state).to.be.oneOf(transactionStates) })
expect(context.location).to.be.oneOf(['Connect#Login', 'RefreshSession#Relogin#WS', 'RefreshSession#REST']) expect(context.location).to.not.equal('RefreshSession#CSDS');
it('Should catch all the success events', function (done) { var got = 0 emitter.on('*.failure', function (shortname, stCode, body) { debug('error *.failure:', shortname, stCode, body) done('*.failure error: wrong event catched.') }) emitter.on('*.success', function (shortname, statusCode, body) { debug('captured events:', got) should.exist(shortname) should.exist(statusCode) should.exist(body) expect(shortname).to.be.oneOf(['hook5', 'hook6']) statusCode.should.equal(200) expect(body).to.be.oneOf(['Path Hit: /5/success', 'Path Hit: /6/success']) ++got if (got === 2) { emitter.removeAllListeners('*.success') emitter.removeAllListeners('*.failure') done() } }) // fire the hooks webHooks.trigger('hook5') webHooks.trigger('hook6') })
it('refreshSession: should call refreshSessionFlow successfully', done => { // Let: requestCSDSStub.yieldsAsync(null, {}, csdsResponse); externalServices.login.yieldsAsync(null, {bearer: 'im encrypted', csrf: 'someCSRF', config: {userId: 'imauser'}}, 'cookies'); externalServices.refreshSession.yieldsAsync(null, {}); const agent = new Agent({ accountId: 'account', username: 'me', password: 'password' }); // If: agent.on('connected', () => { agent.refreshSession((err) => { // Then: // Successful handleRefreshSessionFlow expect(err).to.equal(null); agent.dispose(); done(); }); }); agent.on('success', (context) => { if (context && context.location) { expect(context.location).to.be.oneOf(['Connect#CSDS', 'Connect#Login', 'RefreshSession#Precheck', 'RefreshSession#Relogin#WS', 'RefreshSession#REST', 'RefreshSession#CSDS']); } }) });
it('Should catch all the failure events', function (done) { var got = 0 emitter.on('*.success', function (shortname, stCode, body) { debug('error *.success:', shortname, stCode, body) done('*.success error: wrong event catched.') }) emitter.on('*.failure', function (shortname, statusCode, body) { debug('captured events:', got) should.exist(shortname) should.exist(statusCode) should.exist(body) expect(shortname).to.be.oneOf(['hook7', 'hook8']) statusCode.should.equal(400) expect(body).to.be.oneOf(['Path Hit: /7/fail', 'Path Hit: /8/fail']) ++got if (got === 2) { emitter.removeAllListeners('*.success') emitter.removeAllListeners('*.failure') done() } }) // fire the hooks webHooks.trigger('hook7') webHooks.trigger('hook8') })