Skip to content

Commit

Permalink
Add CLI parser unit tests for logout command
Browse files Browse the repository at this point in the history
  • Loading branch information
narayanpai1 committed Jun 29, 2020
1 parent 75e87ec commit 3121f5b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/unit/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,4 +299,39 @@ describe('cli parser', function () {
});
});
});

describe('Logout Command', function () {
let spy;

before(function () {
// create a new spy
spy = sinon.spy();

// replace the function to be exported from the login module with the spy
require.cache[require.resolve('../../lib/logout')] = {
exports: spy
};
});

after(function () {
// restore original `logout` module.
delete require.cache[require.resolve('../../lib/logout')];
});

it('should work with an alias', function (done) {
cli('node newman.js logout testalias'.split(' '), 'logout', function (err) {
expect(err).to.be.null;
expect(spy.withArgs('testalias').calledOnce).to.be.true;
done();
});
});

it('should work without an alias', function (done) {
cli('node newman.js logout'.split(' '), 'logout', function (err) {
expect(err).to.be.null;
expect(spy.withArgs(undefined).calledOnce).to.be.true;
done();
});
});
});
});

0 comments on commit 3121f5b

Please sign in to comment.