1
1
/// <reference path=".d.ts" />
2
2
"use strict" ;
3
3
4
- import * as yok from "../lib/common/yok" ;
4
+ import { Yok } from "../lib/common/yok" ;
5
5
import * as stubs from "./stubs" ;
6
6
import { CreateProjectCommand } from "../lib/commands/create-project" ;
7
7
import * as constants from "../lib/constants" ;
8
8
import { assert } from "chai" ;
9
9
10
10
let selectedTemplateName : string ;
11
11
let isProjectCreated : boolean ;
12
- let dummyArgsString = "dummyArgsString" ;
12
+ let dummyArgs = [ "dummyArgsString" ] ;
13
13
14
14
class ProjectServiceMock implements IProjectService {
15
15
createProject ( projectName : string , selectedTemplate ?: string ) : IFuture < void > {
@@ -27,7 +27,7 @@ class ProjectNameValidatorMock implements IProjectNameValidator {
27
27
}
28
28
29
29
function createTestInjector ( ) {
30
- let testInjector = new yok . Yok ( ) ;
30
+ let testInjector = new Yok ( ) ;
31
31
32
32
testInjector . register ( "injector" , testInjector ) ;
33
33
testInjector . register ( "staticConfig" , { } ) ;
@@ -44,70 +44,58 @@ function createTestInjector() {
44
44
return testInjector ;
45
45
}
46
46
47
- describe ( ' Project Service Tests' , ( ) => {
47
+ describe ( " Project commands tests" , ( ) => {
48
48
let testInjector : IInjector ;
49
+ let options : IOptions ;
50
+ let createProjectCommand : ICommand ;
49
51
50
52
beforeEach ( ( ) => {
51
53
testInjector = createTestInjector ( ) ;
52
54
isProjectCreated = false ;
55
+ selectedTemplateName = undefined ;
56
+ options = testInjector . resolve ( "$options" ) ;
57
+ createProjectCommand = testInjector . resolve ( "$createCommand" ) ;
53
58
} ) ;
54
59
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 ;
60
63
61
- let createProjectCommand : ICommand = testInjector . resolve ( "$createCommand" ) ;
64
+ createProjectCommand . execute ( dummyArgs ) . wait ( ) ;
62
65
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
+ } ) ;
78
68
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" ;
82
71
83
- let createProjectCommand : ICommand = testInjector . resolve ( "$createCommand" ) ;
72
+ createProjectCommand . execute ( dummyArgs ) . wait ( ) ;
84
73
85
- createProjectCommand . execute ( [ dummyArgsString ] ) . wait ( ) ;
74
+ assert . isTrue ( isProjectCreated ) ;
75
+ } ) ;
86
76
87
- assert . deepEqual ( options . template , constants . ANGULAR_NAME ) ;
88
- } ) ;
77
+ it ( "should set the template name correctly when used --ng." , ( ) => {
78
+ options . ng = true ;
89
79
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 ( ) ;
93
81
94
- let createProjectCommand : ICommand = testInjector . resolve ( "$createCommand" ) ;
82
+ assert . deepEqual ( selectedTemplateName , constants . ANGULAR_NAME ) ;
83
+ } ) ;
95
84
96
- createProjectCommand . execute ( [ dummyArgsString ] ) . wait ( ) ;
85
+ it ( "should not set the template name when --ng is not used." , ( ) => {
86
+ options . ng = false ;
97
87
98
- assert . isUndefined ( options . template ) ;
99
- } ) ;
88
+ createProjectCommand . execute ( dummyArgs ) . wait ( ) ;
100
89
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
+ } ) ;
105
92
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" ;
107
96
108
- assert . throws ( ( ) => {
109
- createProjectCommand . execute ( [ dummyArgsString ] ) . wait ( ) ;
110
- } ) ;
97
+ assert . throws ( ( ) => {
98
+ createProjectCommand . execute ( dummyArgs ) . wait ( ) ;
111
99
} ) ;
112
100
} ) ;
113
101
} ) ;
0 commit comments