Skip to content
This repository was archived by the owner on Dec 17, 2018. It is now read-only.

Commit 35f5d35

Browse files
committed
#71 Unit tests to support npm install/update calls and text formatting of upgrade
1 parent 82f3a5e commit 35f5d35

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

commands/upgrade/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const upgradeFiles = (npmCommand) => erector.inquire([
9494
name: 'proceed',
9595
question: colorize.colorize('The following will overwrite some of the files in your project. Would you like to continue ', 'red') +
9696
'(y/N)' +
97-
colorize.colorize('?', 'magenta'),
97+
colorize.colorize('?', 'red'),
9898
transform: inputs.createYesNoValue('n', [])
9999
}
100100
]).then((answers) => {

test/upgrade.spec.js

+18-10
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,19 @@ tap.test('command: upgrade', (suite) => {
9090
test.plan(6);
9191

9292
make().catch(() => {
93-
test.ok(log.firstCall.calledWith('[cyan]Identifying the *newest* angular-librarian version[/cyan]'));
93+
test.ok(log.firstCall.calledWith('[blue]Identifying the *newest* Angular Librarian version[/blue]'));
9494
test.ok(execute.firstCall.calledWith(
9595
npm,
9696
['show', 'angular-librarian', 'version']
9797
));
98-
test.ok(log.secondCall.calledWith('[blue]Identifying the *installed* angular-librarian version[/blue]'));
98+
test.ok(log.secondCall.calledWith('[blue]Identifying the *installed* Angular Librarian version[/blue]'));
9999
test.ok(execute.secondCall.calledWith(
100100
npm,
101101
['list', '--depth=0', 'angular-librarian']
102102
));
103103
test.ok(gt.calledWith('300.0.1', '300.0.0'));
104104
test.ok(log.thirdCall.calledWith(
105-
'[yellow]\tUpgrade of angular-librarian is[/yellow]',
105+
'[yellow] Upgrade of Angular Librarian is[/yellow]',
106106
'[red]NOT[/red]',
107107
'[yellow]required.[/yellow]'
108108
));
@@ -120,7 +120,7 @@ tap.test('command: upgrade', (suite) => {
120120

121121
make().catch(() => {
122122
test.ok(log.getCall(3).calledWith(
123-
'[green] Installing angular-librarian@300.0.1[/green]'
123+
'[blue]Installing Angular Librarian 300.0.1[/blue]'
124124
));
125125
test.ok(execute.thirdCall.calledWith(
126126
npm,
@@ -139,7 +139,7 @@ tap.test('command: upgrade', (suite) => {
139139
test.plan(3);
140140

141141
make().catch(() => {
142-
test.ok(log.calledWith('[green]Upgrading angular-librarian from:[/green]'));
142+
test.ok(log.calledWith('[blue]Upgrading Angular Librarian from:[/blue]'));
143143
test.ok(log.calledWith('[magenta] ice-cream[/magenta]'));
144144
test.ok(execute.calledWith(
145145
npm,
@@ -161,7 +161,7 @@ tap.test('command: upgrade', (suite) => {
161161
{
162162
allowBlank: true,
163163
name: 'proceed',
164-
question: 'The following will overwrite some of the files in your project. Would you like to continue (y/N)?',
164+
question: '[red]The following will overwrite some of the files in your project. Would you like to continue [/red](y/N)[red]?[/red]',
165165
transform: 'yes-no'
166166
}
167167
]));
@@ -193,7 +193,7 @@ tap.test('command: upgrade', (suite) => {
193193
});
194194
});
195195

196-
suite.test('should upgrade the files when the user answers yes', (test) => {
196+
suite.test('should upgrade the files & dependencies when the user answers yes', (test) => {
197197
const { construct, inquire } = mocks.erector;
198198
const { getTemplates, log } = mocks;
199199
const answers = [
@@ -228,7 +228,7 @@ tap.test('command: upgrade', (suite) => {
228228
open.returns(answers);
229229
inquire.resetBehavior();
230230
inquire.resolves(inquireAnswers);
231-
test.plan(4);
231+
test.plan(6);
232232

233233
make().then(() => {
234234
test.ok(getTemplates.calledWith(
@@ -276,10 +276,18 @@ tap.test('command: upgrade', (suite) => {
276276
));
277277
test.ok(construct.calledWith(finalAnswers, 'fake-templates'));
278278
test.ok(log.calledWith(
279-
'[cyan] Updating managed files to latest versions[/cyan]'
279+
'[blue]Updating managed files to latest versions[/blue]'
280280
));
281281
test.ok(log.calledWith(
282-
'[green]Files have been upgraded![/green]'
282+
'[green] Files have been upgraded![/green]'
283+
));
284+
test.ok(execute.calledWith(
285+
npm,
286+
['i']
287+
));
288+
test.ok(execute.calledWith(
289+
npm,
290+
['up']
283291
));
284292

285293
test.end();

0 commit comments

Comments
 (0)