Skip to content

Commit

Permalink
Minor fix in unit and feature tests
Browse files Browse the repository at this point in the history
  • Loading branch information
1AmNegan committed May 8, 2018
1 parent 62ec112 commit e5b77e5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"post-unit": "nyc report --reporter=lcov > coverage.lcov && codecov -F unit && rm -rf ~/.autolabjs",
"integration": "nyc --reporter=lcov --reporter=text-lcov -s --all mocha 'test/integration/**/*.js'",
"post-integration": "nyc report --reporter=lcov > coverage.lcov && codecov -F integration && rm -rf ~/.autolabjs",
"feature": "rm -rf ~/.autolabjs && nyc --reporter=lcov --reporter=text-lcov -s --all cucumber-js 'test/feature/features' -r 'test/feature/steps'",
"feature": "nyc --reporter=lcov --reporter=text-lcov -s --all cucumber-js 'test/feature/features' -r 'test/feature/steps'",
"post-feature": "nyc report --reporter=lcov > coverage.lcov && codecov -F feature"
},
"bin": {
Expand Down
1 change: 1 addition & 0 deletions test/feature/steps/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ When('I run prefs command with changeserver using {string} for {string}', async
typePromptGenerator.addProperty('type', 'list');
typePromptGenerator.addProperty('message', 'Choose the server type:');
typePromptGenerator.addProperty('choices', ['gitlab', 'ms']);
typePromptGenerator.addProperty('validate', undefined);
const typePrompt = typePromptGenerator.getPrompt();
global.promptStub.withArgs(typePrompt).resolves({ type: serverType });
}
Expand Down
3 changes: 2 additions & 1 deletion test/integration/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ const nock = require('nock');
const inquirer = require('inquirer');
const controller = require('../../lib/controller');
const preferenceManager = require('../../lib/utils/preference-manager');
const host = preferenceManager.getPreference({ name: 'cliPrefs' }).gitlab.host;

chai.use(sinonChai);
chai.should();

describe('Integration test for init command', () => {
const sandbox = sinon.createSandbox();
beforeEach(() => {
const fakeServer = nock('https://autolab.bits-goa.ac.in')
const fakeServer = nock(`https://${host}`)
.post('/api/v4/session?login=testuser2&password=123');
fakeServer.reply(200, {
ok: true,
Expand Down
5 changes: 3 additions & 2 deletions test/unit/lib/model/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ chai.should();

const preferenceManager = require('../../../../lib/utils/preference-manager');
const initModel = require('../../../../lib/model/init');
const host = preferenceManager.getPreference({ name: 'cliPrefs' }).gitlab.host;

chai.use(chaiAsPromised);
chai.should();

describe('for initModel', () => {
it('should return status code 200 after successful login', async () => {
const fakeServer = nock('https://autolab.bits-goa.ac.in')
const fakeServer = nock(`https://${host}`)
.post('/api/v4/session?login=testuser3&password=123');
fakeServer.reply(200, {
ok: true,
Expand All @@ -34,7 +35,7 @@ describe('for initModel', () => {
});

it('should return status code of 401 when invalid login provided', async () => {
const fakeServer = nock('https://autolab.bits-goa.ac.in')
const fakeServer = nock(`https://${host}`)
.post('/api/v4/session?login=testuser&password=123');
fakeServer.reply(401);
const status = await initModel.authenticate({
Expand Down

0 comments on commit e5b77e5

Please sign in to comment.