11/// <reference path=".d.ts" />
22"use strict" ;
33
4- import * as yok from "../lib/common/yok" ;
4+ import { Yok } from "../lib/common/yok" ;
55import * as stubs from "./stubs" ;
66import { CreateProjectCommand } from "../lib/commands/create-project" ;
77import * as constants from "../lib/constants" ;
88import { assert } from "chai" ;
99
1010let selectedTemplateName : string ;
1111let isProjectCreated : boolean ;
12- let dummyArgsString = "dummyArgsString" ;
12+ let dummyArgs = [ "dummyArgsString" ] ;
1313
1414class ProjectServiceMock implements IProjectService {
1515 createProject ( projectName : string , selectedTemplate ?: string ) : IFuture < void > {
@@ -27,7 +27,7 @@ class ProjectNameValidatorMock implements IProjectNameValidator {
2727}
2828
2929function createTestInjector ( ) {
30- let testInjector = new yok . Yok ( ) ;
30+ let testInjector = new Yok ( ) ;
3131
3232 testInjector . register ( "injector" , testInjector ) ;
3333 testInjector . register ( "staticConfig" , { } ) ;
@@ -44,70 +44,58 @@ function createTestInjector() {
4444 return testInjector ;
4545}
4646
47- describe ( ' Project Service Tests' , ( ) => {
47+ describe ( " Project commands tests" , ( ) => {
4848 let testInjector : IInjector ;
49+ let options : IOptions ;
50+ let createProjectCommand : ICommand ;
4951
5052 beforeEach ( ( ) => {
5153 testInjector = createTestInjector ( ) ;
5254 isProjectCreated = false ;
55+ selectedTemplateName = undefined ;
56+ options = testInjector . resolve ( "$options" ) ;
57+ createProjectCommand = testInjector . resolve ( "$createCommand" ) ;
5358 } ) ;
5459
55- describe ( "project commands tests" , ( ) => {
56- describe ( "#CreateProjectCommand" , ( ) => {
57- it ( "should not fail when using only --ng." , ( ) => {
58- let options : IOptions = testInjector . resolve ( "$options" ) ;
59- options . ng = true ;
60+ describe ( "#CreateProjectCommand" , ( ) => {
61+ it ( "should not fail when using only --ng." , ( ) => {
62+ options . ng = true ;
6063
61- let createProjectCommand : ICommand = testInjector . resolve ( "$createCommand" ) ;
64+ createProjectCommand . execute ( dummyArgs ) . wait ( ) ;
6265
63- createProjectCommand . execute ( [ dummyArgsString ] ) . wait ( ) ;
64-
65- assert . isTrue ( isProjectCreated ) ;
66- } ) ;
67-
68- it ( "should not fail when using only --template." , ( ) => {
69- let options : IOptions = testInjector . resolve ( "$options" ) ;
70- options . template = "ng" ;
71-
72- let createProjectCommand : ICommand = testInjector . resolve ( "$createCommand" ) ;
73-
74- createProjectCommand . execute ( [ dummyArgsString ] ) . wait ( ) ;
75-
76- assert . isTrue ( isProjectCreated ) ;
77- } ) ;
66+ assert . isTrue ( isProjectCreated ) ;
67+ } ) ;
7868
79- it ( "should set the template name correctly when used --ng." , ( ) => {
80- let options : IOptions = testInjector . resolve ( "$options" ) ;
81- options . ng = true ;
69+ it ( "should not fail when using only --template." , ( ) => {
70+ options . template = "ng" ;
8271
83- let createProjectCommand : ICommand = testInjector . resolve ( "$createCommand" ) ;
72+ createProjectCommand . execute ( dummyArgs ) . wait ( ) ;
8473
85- createProjectCommand . execute ( [ dummyArgsString ] ) . wait ( ) ;
74+ assert . isTrue ( isProjectCreated ) ;
75+ } ) ;
8676
87- assert . deepEqual ( options . template , constants . ANGULAR_NAME ) ;
88- } ) ;
77+ it ( "should set the template name correctly when used --ng." , ( ) => {
78+ options . ng = true ;
8979
90- it ( "should not set the template name when --ng is not used." , ( ) => {
91- let options : IOptions = testInjector . resolve ( "$options" ) ;
92- options . ng = false ;
80+ createProjectCommand . execute ( dummyArgs ) . wait ( ) ;
9381
94- let createProjectCommand : ICommand = testInjector . resolve ( "$createCommand" ) ;
82+ assert . deepEqual ( selectedTemplateName , constants . ANGULAR_NAME ) ;
83+ } ) ;
9584
96- createProjectCommand . execute ( [ dummyArgsString ] ) . wait ( ) ;
85+ it ( "should not set the template name when --ng is not used." , ( ) => {
86+ options . ng = false ;
9787
98- assert . isUndefined ( options . template ) ;
99- } ) ;
88+ createProjectCommand . execute ( dummyArgs ) . wait ( ) ;
10089
101- it ( "should fail when --ng and --template are used simultaneously." , ( ) => {
102- let options : IOptions = testInjector . resolve ( "$options" ) ;
103- options . ng = true ;
104- options . template = "ng" ;
90+ assert . isUndefined ( selectedTemplateName ) ;
91+ } ) ;
10592
106- let createProjectCommand : ICommand = testInjector . resolve ( "$createCommand" ) ;
93+ it ( "should fail when --ng and --template are used simultaneously." , ( ) => {
94+ options . ng = true ;
95+ options . template = "ng" ;
10796
108- assert . throws ( ( ) => {
109- createProjectCommand . execute ( [ dummyArgsString ] ) . wait ( ) ;
110- } ) ;
97+ assert . throws ( ( ) => {
98+ createProjectCommand . execute ( dummyArgs ) . wait ( ) ;
11199 } ) ;
112100 } ) ;
113101 } ) ;
0 commit comments