|
195 | 195 |
|
196 | 196 | test.equals(currentPattern.lineageIndex.length, 1);
|
197 | 197 | test.equals(currentPattern.lineageIndex[0], "atoms-error");
|
| 198 | + test.equals(patternlab.patterns[0].lineageRIndex.length, 1); |
| 199 | + test.equals(JSON.parse(patternlab.patterns[0].lineageR).lineagePattern, 'molecules-error'); |
198 | 200 |
|
199 | 201 | test.done();
|
200 |
| - } |
| 202 | + }, |
| 203 | + |
| 204 | + 'test lineage hunter does not apply lineage twice' : function(test){ |
| 205 | + //setup current pattern from what we would have during execution |
| 206 | + var currentPattern = { |
| 207 | + "name": "01-molecules-01-toast-00-error", |
| 208 | + "subdir": "01-molecules\\01-toast", |
| 209 | + "filename": "00-error.mustache", |
| 210 | + "data": null, |
| 211 | + "template": "{{>atoms-error(message: 'That\'s no moon...')}}", |
| 212 | + "patternPartial": "{{>atoms-error(message: 'That\'s no moon...')}}", |
| 213 | + "patternName": "error", |
| 214 | + "patternLink": "01-molecules-01-toast-00-error/01-molecules-01-toast-00-error.html", |
| 215 | + "patternGroup": "molecules", |
| 216 | + "patternSubGroup": "molecules\\01-toast", |
| 217 | + "flatPatternPath": "01-molecules\\01-toast", |
| 218 | + "patternState": "", |
| 219 | + "lineage": [], |
| 220 | + "lineageIndex": [], |
| 221 | + "lineageR": [], |
| 222 | + "lineageRIndex": [] |
| 223 | + }; |
| 224 | + var patternlab = { |
| 225 | + patterns: [ |
| 226 | + { |
| 227 | + "name": "01-atoms-05-alerts-00-error", |
| 228 | + "subdir": "01-atoms\\05-alerts", |
| 229 | + "filename": "00-error.mustache", |
| 230 | + "data": null, |
| 231 | + "template": "<h1> {{message}} </h1>", |
| 232 | + "patternPartial": "<h1> {{message}} </h1>", |
| 233 | + "patternName": "error", |
| 234 | + "patternLink": "01-atoms-05-alerts-00-error/01-atoms-05-alerts-00-error.html", |
| 235 | + "patternGroup": "atoms", |
| 236 | + "patternSubGroup": "atoms\\05-alerts", |
| 237 | + "flatPatternPath": "01-atoms\\05-alerts", |
| 238 | + "patternState": "", |
| 239 | + "lineage": [], |
| 240 | + "lineageIndex": [], |
| 241 | + "lineageR": [], |
| 242 | + "lineageRIndex": [] |
| 243 | + } |
| 244 | + ] |
| 245 | + }; |
| 246 | + |
| 247 | + var lineage_hunter = new lh(); |
| 248 | + lineage_hunter.find_lineage(currentPattern, patternlab); |
| 249 | + lineage_hunter.find_lineage(currentPattern, patternlab); |
| 250 | + |
| 251 | + test.equals(currentPattern.lineageIndex.length, 1); |
| 252 | + test.equals(currentPattern.lineageIndex[0], "atoms-error"); |
| 253 | + test.equals(patternlab.patterns[0].lineageRIndex.length, 1); |
| 254 | + test.equals(JSON.parse(patternlab.patterns[0].lineageR).lineagePattern, 'molecules-error'); |
| 255 | + |
| 256 | + test.done(); |
| 257 | + }, |
| 258 | + |
| 259 | + |
201 | 260 | };
|
202 | 261 |
|
203 | 262 | }());
|
0 commit comments