1
+ ( function ( ) {
2
+ "use strict" ;
3
+
4
+ var lh = require ( '../builder/lineage_hunter' ) ;
5
+
6
+ exports [ 'lineage hunter ' ] = {
7
+ 'test lineage hunter finds lineage' : function ( test ) {
8
+
9
+ //setup current pattern from what we would have during execution
10
+ var currentPattern = {
11
+ "name" : "02-organisms-00-global-00-header" ,
12
+ "subdir" : "02-organisms\\00-global" ,
13
+ "filename" : "00-header.mustache" ,
14
+ "data" : null ,
15
+ "template" : "<!-- Begin .header -->\r\n<header class=\"header cf\" role=\"banner\">\r\n\t{{> atoms-logo }}\r\n\t<a href=\"#\" class=\"nav-toggle nav-toggle-search icon-search\"><span class=\"is-vishidden\">Search</span></a>\r\n\t<a href=\"#\" class=\"nav-toggle nav-toggle-menu icon-menu\"><span class=\"is-vishidden\">Menu</span></a>\r\n\t{{> molecules-primary-nav }}\r\n\t{{> molecules-search }}\r\n</header>\r\n<!-- End .header -->\r\n" ,
16
+ "patternPartial" : "<!-- Begin .header -->\r\n<header class=\"header cf\" role=\"banner\">\r\n<a href=\"/\"><img src=\"../../images/logo.png\" class=\"logo\" alt=\"Logo Alt Text\" /></a>\t<a href=\"#\" class=\"nav-toggle nav-toggle-search icon-search\"><span class=\"is-vishidden\">Search</span></a>\r\n\t<a href=\"#\" class=\"nav-toggle nav-toggle-menu icon-menu\"><span class=\"is-vishidden\">Menu</span></a>\r\n<nav id=\"nav\" class=\"nav\">\r\n\t<ul>\r\n\t\t<li><a href=\"#\">Home</a></li>\r\n\t\t<li><a href=\"#\">About</a></li>\r\n\t\t<li><a href=\"#\">Blog</a></li>\r\n\t\t<li><a href=\"#\">Contact</a></li>\r\n\t</ul>\r\n</nav><!--end .nav-->\r\n<form action=\"#\" method=\"post\" class=\"inline-form search-form\"> \r\n <fieldset>\r\n\t <legend class=\"is-vishidden\">Search</legend>\r\n\t <label for=\"search-field\" class=\"is-vishidden\">Search</label>\r\n\t <input type=\"search\" placeholder=\"Search\" id=\"search-field\" class=\"search-field\" />\r\n\t <button class=\"search-submit\">\r\n\t \t<span class=\"icon-search\" aria-hidden=\"true\"></span>\r\n\t \t<span class=\"is-vishidden\">Search</span>\r\n\t </button>\r\n </fieldset>\r\n</form></header>\r\n<!-- End .header -->\r\n" ,
17
+ "patternName" : "header" ,
18
+ "patternLink" : "02-organisms-00-global-00-header/02-organisms-00-global-00-header.html" ,
19
+ "patternGroup" : "organisms" ,
20
+ "patternSubGroup" : "organisms\\00-global" ,
21
+ "flatPatternPath" : "02-organisms\\00-global" ,
22
+ "patternState" : ""
23
+ } ;
24
+ var patternlab = {
25
+ patterns : [
26
+ {
27
+ "name" : "00-atoms-03-images-00-logo" ,
28
+ "subdir" : "00-atoms\\03-images" ,
29
+ "filename" : "00-logo.mustache" ,
30
+ "data" : null ,
31
+ "template" : "<a href=\"/\"><img src=\"../../images/logo.png\" class=\"logo\" alt=\"Logo Alt Text\" /></a>" ,
32
+ "patternPartial" : "<a href=\"/\"><img src=\"../../images/logo.png\" class=\"logo\" alt=\"Logo Alt Text\" /></a>" ,
33
+ "patternName" : "logo" ,
34
+ "patternLink" : "00-atoms-03-images-00-logo/00-atoms-03-images-00-logo.html" ,
35
+ "patternGroup" : "atoms" ,
36
+ "patternSubGroup" : "atoms\\03-images" ,
37
+ "flatPatternPath" : "00-atoms\\03-images" ,
38
+ "patternState" : ""
39
+ } ,
40
+ {
41
+ "name" : "01-molecules-05-navigation-00-primary-nav" ,
42
+ "subdir" : "01-molecules\\05-navigation" ,
43
+ "filename" : "00-primary-nav.mustache" ,
44
+ "data" : null ,
45
+ "template" : "<nav id=\"nav\" class=\"nav\">\r\n\t<ul>\r\n\t\t<li><a href=\"#\">Home</a></li>\r\n\t\t<li><a href=\"#\">About</a></li>\r\n\t\t<li><a href=\"#\">Blog</a></li>\r\n\t\t<li><a href=\"#\">Contact</a></li>\r\n\t</ul>\r\n</nav><!--end .nav-->\r\n" ,
46
+ "patternPartial" : "<nav id=\"nav\" class=\"nav\">\r\n\t<ul>\r\n\t\t<li><a href=\"#\">Home</a></li>\r\n\t\t<li><a href=\"#\">About</a></li>\r\n\t\t<li><a href=\"#\">Blog</a></li>\r\n\t\t<li><a href=\"#\">Contact</a></li>\r\n\t</ul>\r\n</nav><!--end .nav-->\r\n" ,
47
+ "patternName" : "primary-nav" ,
48
+ "patternLink" : "01-molecules-05-navigation-00-primary-nav/01-molecules-05-navigation-00-primary-nav.html" ,
49
+ "patternGroup" : "molecules" ,
50
+ "patternSubGroup" : "molecules\\05-navigation" ,
51
+ "flatPatternPath" : "01-molecules\\05-navigation" ,
52
+ "patternState" : ""
53
+ } ,
54
+ {
55
+ "name" : "01-molecules-04-forms-00-search" ,
56
+ "subdir" : "01-molecules\\04-forms" ,
57
+ "filename" : "00-search.mustache" ,
58
+ "data" : null ,
59
+ "template" : "<form action=\"#\" method=\"post\" class=\"inline-form search-form\"> \r\n <fieldset>\r\n\t <legend class=\"is-vishidden\">Search</legend>\r\n\t <label for=\"search-field\" class=\"is-vishidden\">Search</label>\r\n\t <input type=\"search\" placeholder=\"Search\" id=\"search-field\" class=\"search-field\" />\r\n\t <button class=\"search-submit\">\r\n\t \t<span class=\"icon-search\" aria-hidden=\"true\"></span>\r\n\t \t<span class=\"is-vishidden\">Search</span>\r\n\t </button>\r\n </fieldset>\r\n</form>" ,
60
+ "patternPartial" : "<form action=\"#\" method=\"post\" class=\"inline-form search-form\"> \r\n <fieldset>\r\n\t <legend class=\"is-vishidden\">Search</legend>\r\n\t <label for=\"search-field\" class=\"is-vishidden\">Search</label>\r\n\t <input type=\"search\" placeholder=\"Search\" id=\"search-field\" class=\"search-field\" />\r\n\t <button class=\"search-submit\">\r\n\t \t<span class=\"icon-search\" aria-hidden=\"true\"></span>\r\n\t \t<span class=\"is-vishidden\">Search</span>\r\n\t </button>\r\n </fieldset>\r\n</form>" ,
61
+ "patternName" : "search" ,
62
+ "patternLink" : "01-molecules-04-forms-00-search/01-molecules-04-forms-00-search.html" ,
63
+ "patternGroup" : "molecules" ,
64
+ "patternSubGroup" : "molecules\\04-forms" ,
65
+ "flatPatternPath" : "01-molecules\\04-forms" ,
66
+ "patternState" : ""
67
+ }
68
+ ]
69
+ } ;
70
+
71
+ var lineage_hunter = new lh ( ) ;
72
+ lineage_hunter . find_lineage ( currentPattern , patternlab ) ;
73
+
74
+ test . equals ( currentPattern . lineageIndex . length , 3 ) ;
75
+ test . equals ( currentPattern . lineageIndex [ 0 ] , "atoms-logo" ) ;
76
+ test . equals ( currentPattern . lineageIndex [ 1 ] , "molecules-primary-nav" ) ;
77
+ test . equals ( currentPattern . lineageIndex [ 2 ] , "molecules-search" ) ;
78
+
79
+ test . done ( ) ;
80
+ }
81
+ } ;
82
+
83
+ } ( ) ) ;
0 commit comments