@@ -63,18 +63,54 @@ describe("generator-biojs-webcomponents:app - Make a new Web Component", () => {
63
63
] ) ;
64
64
} ) ;
65
65
} ) ;
66
- it ( "throws an error if user enters an empty string as toolNameHuman " , async ( ) => {
66
+ it ( "passes if toolNameComputer is correctly formatted " , async ( ) => {
67
67
assert . equal (
68
- await validators . toolNameHuman ( " ") ,
69
- chalk . red ( "This is a mandatory field, please answer." )
68
+ await validators . toolNameComputer ( "tool-name-computer-1 ") ,
69
+ true
70
70
) ;
71
71
} ) ;
72
+ it ( "passes if toolNameHuman is correctly formatted" , async ( ) => {
73
+ assert . equal ( await validators . toolNameHuman ( "Tool Name Human" ) , true ) ;
74
+ } ) ;
75
+ it ( "throws an error if toolNameComputer is wrongly formatted" , async ( ) => {
76
+ let err1 = await validators . toolNameComputer ( "-tool-name" ) ;
77
+ let err2 = await validators . toolNameComputer ( "tool-name-" ) ;
78
+ let err3 = await validators . toolNameComputer ( "toolName-computer" ) ;
79
+ let err4 = await validators . toolNameComputer ( "*toolname-comp" ) ;
80
+ let err5 = await validators . toolNameComputer ( "tool name" ) ;
81
+ if (
82
+ err1 !== true &&
83
+ err2 !== true &&
84
+ err3 !== true &&
85
+ err4 !== true &&
86
+ err5 !== true
87
+ ) {
88
+ assert . ok ( true ) ;
89
+ } else {
90
+ assert . fail ( ) ;
91
+ }
92
+ } ) ;
93
+ it ( "throws an error if toolNameHuman is wrongly formatted" , async ( ) => {
94
+ let err1 = await validators . toolNameHuman ( "tool-name" ) ;
95
+ let err2 = await validators . toolNameHuman ( "toolname1" ) ;
96
+ if ( err1 !== true && err2 !== true ) {
97
+ assert . ok ( true ) ;
98
+ } else {
99
+ assert . fail ( ) ;
100
+ }
101
+ } ) ;
72
102
it ( "throws an error if user enters an empty string as toolNameComputer" , async ( ) => {
73
103
assert . equal (
74
104
await validators . toolNameComputer ( "" ) ,
75
105
chalk . red ( "This is a mandatory field, please answer." )
76
106
) ;
77
107
} ) ;
108
+ it ( "throws an error if user enters an empty string as toolNameHuman" , async ( ) => {
109
+ assert . equal (
110
+ await validators . toolNameHuman ( "" ) ,
111
+ chalk . red ( "This is a mandatory field, please answer." )
112
+ ) ;
113
+ } ) ;
78
114
} ) ;
79
115
80
116
describe ( "generator-biojs-webcomponents:app - Upgrade an existing component by importing build file locally" , ( ) => {
@@ -83,6 +119,10 @@ describe("generator-biojs-webcomponents:app - Upgrade an existing component by i
83
119
assert . file ( "test-component" ) ;
84
120
} ) ;
85
121
} ) ;
122
+ it ( "does not throw an error if user enters path of a project directory which already exists" , async ( ) => {
123
+ let res = await validators . storeArg ( "test-component" ) ;
124
+ assert . equal ( res , true ) ;
125
+ } ) ;
86
126
it ( "makes a new directory named - component-dist" , async ( ) => {
87
127
await validators
88
128
. directoryName ( "component-dist" )
@@ -97,6 +137,18 @@ describe("generator-biojs-webcomponents:app - Upgrade an existing component by i
97
137
assert . file ( [ "test-component/component-dist/validator.js" ] ) ;
98
138
} ) ;
99
139
} ) ;
140
+ it ( "overwrites the directory content if user enters o or O" , async ( ) => {
141
+ await validators
142
+ . directoryName ( "o" )
143
+ . then ( ( ) =>
144
+ assert . noFile ( [ "test-component/component-dist/validator.js" ] )
145
+ ) ;
146
+ } ) ;
147
+ it ( "makes a new directory if user enters a new name" , async ( ) => {
148
+ await validators . directoryName ( "new-build-dir" ) . then ( ( ) => {
149
+ assert . file ( "test-component/new-build-dir" ) ;
150
+ } ) ;
151
+ } ) ;
100
152
it ( "throws an error if user enters an empty string as path of build file" , async ( ) => {
101
153
assert . equal (
102
154
await validators . importBuildFileFromNPM ( "" ) ,
0 commit comments