@@ -63,6 +63,66 @@ tap.test('test Pattern initializes correctly', function(test) {
63
63
test . end ( ) ;
64
64
} ) ;
65
65
66
+ tap . test (
67
+ 'test Pattern initializes correctly with pattern in sepatated directory' ,
68
+ function ( test ) {
69
+ var p = new Pattern ( '00-atoms/00-global/00-colors/colors.mustache' , {
70
+ d : 123 ,
71
+ } ) ;
72
+ test . equals (
73
+ p . relPath ,
74
+ '00-atoms' +
75
+ path . sep +
76
+ '00-global' +
77
+ path . sep +
78
+ '00-colors' +
79
+ path . sep +
80
+ 'colors.mustache'
81
+ ) ;
82
+ test . equals ( p . name , '00-atoms-00-global-00-colors' ) ;
83
+ test . equals (
84
+ p . subdir ,
85
+ '00-atoms' + path . sep + '00-global' + path . sep + '00-colors'
86
+ ) ;
87
+ test . equals ( p . fileName , 'colors' ) ;
88
+ test . equals ( p . fileExtension , '.mustache' ) ;
89
+ test . equals ( p . jsonFileData . d , 123 ) ;
90
+ test . equals ( p . patternBaseName , 'colors' ) ;
91
+ test . equals ( p . patternName , 'Colors' ) ;
92
+ test . equals (
93
+ p . getPatternLink ( pl ) ,
94
+ '00-atoms-00-global-00-colors' +
95
+ path . sep +
96
+ '00-atoms-00-global-00-colors.rendered.html'
97
+ ) ;
98
+ test . equals ( p . patternGroup , 'atoms' ) ;
99
+ test . equals ( p . patternSubGroup , 'global' ) ;
100
+ test . equals ( p . flatPatternPath , '00-atoms-00-global' ) ;
101
+ test . equals ( p . patternPartial , 'atoms-colors' ) ;
102
+ test . equals ( p . template , '' ) ;
103
+ test . equals ( p . patternPartialCode , '' ) ;
104
+ test . equals ( p . lineage . length , 0 ) ;
105
+ test . equals ( p . lineageIndex . length , 0 ) ;
106
+ test . equals ( p . lineageR . length , 0 ) ;
107
+ test . equals ( p . lineageRIndex . length , 0 ) ;
108
+ test . equals ( p . patternState , '' ) ;
109
+ test . end ( ) ;
110
+ }
111
+ ) ;
112
+
113
+ tap . test ( 'test Pattern name for variants correctly initialzed' , function ( test ) {
114
+ var p1 = new Pattern ( '00-atoms/00-global/00-colors/colors~variant.mustache' , {
115
+ d : 123 ,
116
+ } ) ;
117
+ var p2 = new Pattern (
118
+ '00-atoms/00-global/00-colors/colors~variant-minus.json' ,
119
+ { d : 123 }
120
+ ) ;
121
+ test . equals ( p1 . name , '00-atoms-00-global-00-colors-variant' ) ;
122
+ test . equals ( p2 . name , '00-atoms-00-global-00-colors-variant-minus' ) ;
123
+ test . end ( ) ;
124
+ } ) ;
125
+
66
126
tap . test ( 'test Pattern with one-directory subdir works as expected' , function (
67
127
test
68
128
) {
@@ -118,6 +178,49 @@ tap.test('test Pattern capitalizes patternDisplayName correctly', function(
118
178
test . end ( ) ;
119
179
} ) ;
120
180
181
+ tap . test ( 'test Pattern get dir level no sepatated pattern directory' , function (
182
+ test
183
+ ) {
184
+ var p = new Pattern ( '00-atoms/00-global/00-colors-alt.mustache' , { d : 123 } ) ;
185
+ console . log ( p ) ;
186
+ test . equals ( p . getDirLevel ( 0 , { hasDir : false , dirLevel : 2 } ) , '00-atoms' ) ;
187
+ test . equals ( p . getDirLevel ( 1 , { hasDir : false , dirLevel : 2 } ) , '00-global' ) ;
188
+ test . equals ( p . getDirLevel ( 3 , { hasDir : false , dirLevel : 2 } ) , '' ) ;
189
+ var p = new Pattern ( '00-atoms/00-colors-alt.mustache' , { d : 123 } ) ;
190
+ test . equals ( p . getDirLevel ( 0 , { hasDir : false , dirLevel : 1 } ) , '00-atoms' ) ;
191
+ test . equals ( p . getDirLevel ( 1 , { hasDir : false , dirLevel : 1 } ) , '00-atoms' ) ;
192
+ test . equals ( p . getDirLevel ( 3 , { hasDir : false , dirLevel : 1 } ) , '' ) ;
193
+ var p = new Pattern ( '00-colors-alt.mustache' , { d : 123 } ) ;
194
+ test . equals ( p . getDirLevel ( 0 , { hasDir : false , dirLevel : 0 } ) , '' ) ;
195
+ test . equals ( p . getDirLevel ( 1 , { hasDir : false , dirLevel : 0 } ) , '' ) ;
196
+ test . equals ( p . getDirLevel ( 3 , { hasDir : false , dirLevel : 0 } ) , '' ) ;
197
+ test . end ( ) ;
198
+ } ) ;
199
+
200
+ tap . test (
201
+ 'test Pattern get dir level with sepatated pattern directory' ,
202
+ function ( test ) {
203
+ var p = new Pattern (
204
+ '00-atoms/00-global/00-colors-alt/colors-alt.mustache' ,
205
+ { d : 123 }
206
+ ) ;
207
+ test . equals ( p . getDirLevel ( 0 , { hasDir : true , dirLevel : 3 } ) , '00-atoms' ) ;
208
+ test . equals ( p . getDirLevel ( 1 , { hasDir : true , dirLevel : 3 } ) , '00-global' ) ;
209
+ test . equals ( p . getDirLevel ( 3 , { hasDir : true , dirLevel : 3 } ) , '' ) ;
210
+ var p = new Pattern ( '00-atoms/00-colors-alt/colors-alt.mustache' , {
211
+ d : 123 ,
212
+ } ) ;
213
+ test . equals ( p . getDirLevel ( 0 , { hasDir : true , dirLevel : 2 } ) , '00-atoms' ) ;
214
+ test . equals ( p . getDirLevel ( 1 , { hasDir : true , dirLevel : 2 } ) , '00-atoms' ) ;
215
+ test . equals ( p . getDirLevel ( 3 , { hasDir : true , dirLevel : 2 } ) , '' ) ;
216
+ var p = new Pattern ( '00-colors-alt/colors-alt.mustache' , { d : 123 } ) ;
217
+ test . equals ( p . getDirLevel ( 0 , { hasDir : true , dirLevel : 1 } ) , '' ) ;
218
+ test . equals ( p . getDirLevel ( 1 , { hasDir : true , dirLevel : 1 } ) , '' ) ;
219
+ test . equals ( p . getDirLevel ( 3 , { hasDir : true , dirLevel : 1 } ) , '' ) ;
220
+ test . end ( ) ;
221
+ }
222
+ ) ;
223
+
121
224
tap . test ( 'The forms of Pattern.getPatternLink() work as expected' , function (
122
225
test
123
226
) {
@@ -146,5 +249,11 @@ tap.test('The forms of Pattern.getPatternLink() work as expected', function(
146
249
path . sep +
147
250
'00-atoms-00-global-00-colors.markup-only.html'
148
251
) ;
252
+ test . equals (
253
+ p . getPatternLink ( pl , 'custom' , '.custom-extension' ) ,
254
+ '00-atoms-00-global-00-colors' +
255
+ path . sep +
256
+ '00-atoms-00-global-00-colors.custom-extension'
257
+ ) ;
149
258
test . end ( ) ;
150
259
} ) ;
0 commit comments