-
-
Notifications
You must be signed in to change notification settings - Fork 405
/
Copy pathroute-help.js
39 lines (35 loc) · 1.2 KB
/
route-help.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict';
const proxyquire = require('proxyquire');
const sinon = require('sinon');
const inquirer = require('inquirer');
const Router = require('../lib/router');
describe('help route', () => {
beforeEach(function () {
this.sandbox = sinon.createSandbox();
this.homeRoute = sinon.stub().returns(Promise.resolve());
this.router = new Router(sinon.stub());
this.router.registerRoute('home', this.homeRoute);
this.open = sinon.stub();
const helpRoute = proxyquire('../lib/routes/help', {
open: this.open
});
this.router.registerRoute('help', helpRoute);
});
afterEach(function () {
this.sandbox.restore();
});
it('allow returning home', function () {
this.sandbox.stub(inquirer, 'prompt').returns(Promise.resolve({whereTo: 'home'}));
return this.router.navigate('help').then(() => {
sinon.assert.calledOnce(this.homeRoute);
});
});
it('open urls in browsers', function () {
const url = 'http://yeoman.io';
this.sandbox.stub(inquirer, 'prompt').returns(Promise.resolve({whereTo: url}));
return this.router.navigate('help').then(() => {
sinon.assert.calledWith(this.open, url);
sinon.assert.calledOnce(this.open);
});
});
});