|
4 | 4 | var lh = require('../builder/lineage_hunter');
|
5 | 5 |
|
6 | 6 | exports['lineage hunter '] = {
|
7 |
| - 'test lineage hunter finds lineage' : function(test){ |
| 7 | + 'find_lineage - finds lineage' : function(test){ |
8 | 8 |
|
9 | 9 | //setup current pattern from what we would have during execution
|
10 | 10 | var currentPattern = {
|
|
19 | 19 | "patternGroup": "organisms",
|
20 | 20 | "patternSubGroup": "organisms\\00-global",
|
21 | 21 | "flatPatternPath": "02-organisms\\00-global",
|
| 22 | + "key": "organisms-header", |
22 | 23 | "patternState": "",
|
23 | 24 | "lineage": [],
|
24 | 25 | "lineageIndex": [],
|
|
39 | 40 | "patternGroup": "atoms",
|
40 | 41 | "patternSubGroup": "atoms\\03-images",
|
41 | 42 | "flatPatternPath": "00-atoms\\03-images",
|
| 43 | + "key": "atoms-logo", |
42 | 44 | "patternState": "",
|
43 | 45 | "lineage": [],
|
44 | 46 | "lineageIndex": [],
|
|
57 | 59 | "patternGroup": "molecules",
|
58 | 60 | "patternSubGroup": "molecules\\05-navigation",
|
59 | 61 | "flatPatternPath": "01-molecules\\05-navigation",
|
| 62 | + "key": "molecules-primary-nav", |
60 | 63 | "patternState": "",
|
61 | 64 | "lineage": [],
|
62 | 65 | "lineageIndex": [],
|
|
75 | 78 | "patternGroup": "molecules",
|
76 | 79 | "patternSubGroup": "molecules\\04-forms",
|
77 | 80 | "flatPatternPath": "01-molecules\\04-forms",
|
| 81 | + "key": "molecules-search", |
78 | 82 | "patternState": "",
|
79 | 83 | "lineage": [],
|
80 | 84 | "lineageIndex": [],
|
|
95 | 99 | test.done();
|
96 | 100 | },
|
97 | 101 |
|
98 |
| - 'test lineage hunter finds lineage with spaced pattern parameters' : function(test){ |
| 102 | + 'find_lineage - finds lineage with spaced pattern parameters' : function(test){ |
99 | 103 | //setup current pattern from what we would have during execution
|
100 | 104 | var currentPattern = {
|
101 | 105 | "name": "01-molecules-01-toast-00-error",
|
|
109 | 113 | "patternGroup": "molecules",
|
110 | 114 | "patternSubGroup": "molecules\\01-toast",
|
111 | 115 | "flatPatternPath": "01-molecules\\01-toast",
|
| 116 | + "key": "molecules-error", |
112 | 117 | "patternState": "",
|
113 | 118 | "lineage": [],
|
114 | 119 | "lineageIndex": [],
|
|
129 | 134 | "patternGroup": "atoms",
|
130 | 135 | "patternSubGroup": "atoms\\05-alerts",
|
131 | 136 | "flatPatternPath": "01-atoms\\05-alerts",
|
| 137 | + "key": "atoms-error", |
132 | 138 | "patternState": "",
|
133 | 139 | "lineage": [],
|
134 | 140 | "lineageIndex": [],
|
|
147 | 153 | test.done();
|
148 | 154 | },
|
149 | 155 |
|
150 |
| - 'test lineage hunter finds lineage with unspaced pattern parameters' : function(test){ |
| 156 | + 'find_lineage - finds lineage with unspaced pattern parameters' : function(test){ |
151 | 157 | //setup current pattern from what we would have during execution
|
152 | 158 | var currentPattern = {
|
153 | 159 | "name": "01-molecules-01-toast-00-error",
|
|
161 | 167 | "patternGroup": "molecules",
|
162 | 168 | "patternSubGroup": "molecules\\01-toast",
|
163 | 169 | "flatPatternPath": "01-molecules\\01-toast",
|
| 170 | + "key": "molecules-error", |
164 | 171 | "patternState": "",
|
165 | 172 | "lineage": [],
|
166 | 173 | "lineageIndex": [],
|
|
181 | 188 | "patternGroup": "atoms",
|
182 | 189 | "patternSubGroup": "atoms\\05-alerts",
|
183 | 190 | "flatPatternPath": "01-atoms\\05-alerts",
|
| 191 | + "key": "atoms-error", |
184 | 192 | "patternState": "",
|
185 | 193 | "lineage": [],
|
186 | 194 | "lineageIndex": [],
|
|
201 | 209 | test.done();
|
202 | 210 | },
|
203 | 211 |
|
204 |
| - 'test lineage hunter does not apply lineage twice' : function(test){ |
| 212 | + 'find_lineage - finds lineage with spaced styleModifier' : function(test){ |
| 213 | + //setup current pattern from what we would have during execution |
| 214 | + var currentPattern = { |
| 215 | + "name": "01-molecules-01-toast-00-error", |
| 216 | + "subdir": "01-molecules\\01-toast", |
| 217 | + "filename": "00-error.mustache", |
| 218 | + "data": null, |
| 219 | + "template": "{{> atoms-error:foo }}", |
| 220 | + "patternPartial": "{{> atoms-error:foo }}", |
| 221 | + "patternName": "error", |
| 222 | + "patternLink": "01-molecules-01-toast-00-error/01-molecules-01-toast-00-error.html", |
| 223 | + "patternGroup": "molecules", |
| 224 | + "patternSubGroup": "molecules\\01-toast", |
| 225 | + "flatPatternPath": "01-molecules\\01-toast", |
| 226 | + "key": "molecules-error", |
| 227 | + "patternState": "", |
| 228 | + "lineage": [], |
| 229 | + "lineageIndex": [], |
| 230 | + "lineageR": [], |
| 231 | + "lineageRIndex": [] |
| 232 | + }; |
| 233 | + var patternlab = { |
| 234 | + patterns: [ |
| 235 | + { |
| 236 | + "name": "01-atoms-05-alerts-00-error", |
| 237 | + "subdir": "01-atoms\\05-alerts", |
| 238 | + "filename": "00-error.mustache", |
| 239 | + "data": null, |
| 240 | + "template": "<h1> {{message}} </h1>", |
| 241 | + "patternPartial": "<h1> {{message}} </h1>", |
| 242 | + "patternName": "error", |
| 243 | + "patternLink": "01-atoms-05-alerts-00-error/01-atoms-05-alerts-00-error.html", |
| 244 | + "patternGroup": "atoms", |
| 245 | + "patternSubGroup": "atoms\\05-alerts", |
| 246 | + "flatPatternPath": "01-atoms\\05-alerts", |
| 247 | + "key": "atoms-error", |
| 248 | + "patternState": "", |
| 249 | + "lineage": [], |
| 250 | + "lineageIndex": [], |
| 251 | + "lineageR": [], |
| 252 | + "lineageRIndex": [] |
| 253 | + } |
| 254 | + ] |
| 255 | + }; |
| 256 | + |
| 257 | + var lineage_hunter = new lh(); |
| 258 | + lineage_hunter.find_lineage(currentPattern, patternlab); |
| 259 | + |
| 260 | + test.equals(currentPattern.lineageIndex.length, 1); |
| 261 | + test.equals(currentPattern.lineageIndex[0], "atoms-error"); |
| 262 | + |
| 263 | + test.done(); |
| 264 | + }, |
| 265 | + |
| 266 | + 'find_lineage - finds lineage with unspaced styleModifier' : function(test){ |
| 267 | + //setup current pattern from what we would have during execution |
| 268 | + var currentPattern = { |
| 269 | + "name": "01-molecules-01-toast-00-error", |
| 270 | + "subdir": "01-molecules\\01-toast", |
| 271 | + "filename": "00-error.mustache", |
| 272 | + "data": null, |
| 273 | + "template": "{{> atoms-error:foo }}", |
| 274 | + "patternPartial": "{{>atoms-error:foo}}", |
| 275 | + "patternName": "error", |
| 276 | + "patternLink": "01-molecules-01-toast-00-error/01-molecules-01-toast-00-error.html", |
| 277 | + "patternGroup": "molecules", |
| 278 | + "patternSubGroup": "molecules\\01-toast", |
| 279 | + "flatPatternPath": "01-molecules\\01-toast", |
| 280 | + "key": "molecules-error", |
| 281 | + "patternState": "", |
| 282 | + "lineage": [], |
| 283 | + "lineageIndex": [], |
| 284 | + "lineageR": [], |
| 285 | + "lineageRIndex": [] |
| 286 | + }; |
| 287 | + var patternlab = { |
| 288 | + patterns: [ |
| 289 | + { |
| 290 | + "name": "01-atoms-05-alerts-00-error", |
| 291 | + "subdir": "01-atoms\\05-alerts", |
| 292 | + "filename": "00-error.mustache", |
| 293 | + "data": null, |
| 294 | + "template": "<h1> {{message}} </h1>", |
| 295 | + "patternPartial": "<h1> {{message}} </h1>", |
| 296 | + "patternName": "error", |
| 297 | + "patternLink": "01-atoms-05-alerts-00-error/01-atoms-05-alerts-00-error.html", |
| 298 | + "patternGroup": "atoms", |
| 299 | + "patternSubGroup": "atoms\\05-alerts", |
| 300 | + "flatPatternPath": "01-atoms\\05-alerts", |
| 301 | + "key": "atoms-error", |
| 302 | + "patternState": "", |
| 303 | + "lineage": [], |
| 304 | + "lineageIndex": [], |
| 305 | + "lineageR": [], |
| 306 | + "lineageRIndex": [] |
| 307 | + } |
| 308 | + ] |
| 309 | + }; |
| 310 | + |
| 311 | + var lineage_hunter = new lh(); |
| 312 | + lineage_hunter.find_lineage(currentPattern, patternlab); |
| 313 | + |
| 314 | + test.equals(currentPattern.lineageIndex.length, 1); |
| 315 | + test.equals(currentPattern.lineageIndex[0], "atoms-error"); |
| 316 | + |
| 317 | + test.done(); |
| 318 | + }, |
| 319 | + |
| 320 | + 'find_lineage - finds lineage with fuzzy partial with styleModifier' : function(test){ |
| 321 | + //setup current pattern from what we would have during execution |
| 322 | + var currentPattern = { |
| 323 | + "name": "01-molecules-01-toast-00-error", |
| 324 | + "subdir": "01-molecules\\01-toast", |
| 325 | + "filename": "00-error.mustache", |
| 326 | + "data": null, |
| 327 | + "template": "{{> atoms-e:foo }}", |
| 328 | + "patternPartial": "{{>atoms-e:foo}}", |
| 329 | + "patternName": "error", |
| 330 | + "patternLink": "01-molecules-01-toast-00-error/01-molecules-01-toast-00-error.html", |
| 331 | + "patternGroup": "molecules", |
| 332 | + "patternSubGroup": "molecules\\01-toast", |
| 333 | + "flatPatternPath": "01-molecules\\01-toast", |
| 334 | + "key": "molecules-error", |
| 335 | + "patternState": "", |
| 336 | + "lineage": [], |
| 337 | + "lineageIndex": [], |
| 338 | + "lineageR": [], |
| 339 | + "lineageRIndex": [] |
| 340 | + }; |
| 341 | + var patternlab = { |
| 342 | + patterns: [ |
| 343 | + { |
| 344 | + "name": "01-atoms-05-alerts-00-error", |
| 345 | + "subdir": "01-atoms\\05-alerts", |
| 346 | + "filename": "00-error.mustache", |
| 347 | + "data": null, |
| 348 | + "template": "<h1> {{message}} </h1>", |
| 349 | + "patternPartial": "<h1> {{message}} </h1>", |
| 350 | + "patternName": "error", |
| 351 | + "patternLink": "01-atoms-05-alerts-00-error/01-atoms-05-alerts-00-error.html", |
| 352 | + "patternGroup": "atoms", |
| 353 | + "patternSubGroup": "atoms\\05-alerts", |
| 354 | + "flatPatternPath": "01-atoms\\05-alerts", |
| 355 | + "key": "atoms-error", |
| 356 | + "patternState": "", |
| 357 | + "lineage": [], |
| 358 | + "lineageIndex": [], |
| 359 | + "lineageR": [], |
| 360 | + "lineageRIndex": [] |
| 361 | + } |
| 362 | + ] |
| 363 | + }; |
| 364 | + |
| 365 | + var lineage_hunter = new lh(); |
| 366 | + lineage_hunter.find_lineage(currentPattern, patternlab); |
| 367 | + |
| 368 | + test.equals(currentPattern.lineageIndex.length, 1); |
| 369 | + test.equals(currentPattern.lineageIndex[0], "atoms-error"); |
| 370 | + |
| 371 | + test.done(); |
| 372 | + }, |
| 373 | + |
| 374 | + 'find_lineage - does not apply lineage twice' : function(test){ |
205 | 375 | //setup current pattern from what we would have during execution
|
206 | 376 | var currentPattern = {
|
207 | 377 | "name": "01-molecules-01-toast-00-error",
|
|
215 | 385 | "patternGroup": "molecules",
|
216 | 386 | "patternSubGroup": "molecules\\01-toast",
|
217 | 387 | "flatPatternPath": "01-molecules\\01-toast",
|
| 388 | + "key": "molecules-error", |
218 | 389 | "patternState": "",
|
219 | 390 | "lineage": [],
|
220 | 391 | "lineageIndex": [],
|
|
235 | 406 | "patternGroup": "atoms",
|
236 | 407 | "patternSubGroup": "atoms\\05-alerts",
|
237 | 408 | "flatPatternPath": "01-atoms\\05-alerts",
|
| 409 | + "key": "atoms-error", |
238 | 410 | "patternState": "",
|
239 | 411 | "lineage": [],
|
240 | 412 | "lineageIndex": [],
|
|
254 | 426 | test.equals(JSON.parse(patternlab.patterns[0].lineageR).lineagePattern, 'molecules-error');
|
255 | 427 |
|
256 | 428 | test.done();
|
257 |
| - }, |
258 |
| - |
| 429 | + } |
259 | 430 |
|
260 | 431 | };
|
261 | 432 |
|
|
0 commit comments