|
| 1 | +(function () { |
| 2 | + "use strict"; |
| 3 | + |
| 4 | + var lih = require('../builder/list_item_hunter'); |
| 5 | + |
| 6 | + exports['list_item_hunter'] = { |
| 7 | + 'process_list_item_partials finds and outputs basic repeating blocks' : function(test){ |
| 8 | + //arrange |
| 9 | + //setup current pattern from what we would have during execution |
| 10 | + var currentPattern = { |
| 11 | + "template": "{{#listItems.two}}{{ title }}{{/listItems.two}}", |
| 12 | + "extendedTemplate" : "{{#listItems.two}}{{ title }}{{/listItems.two}}", |
| 13 | + "key": "test-patternName", |
| 14 | + "jsonFileData" : {} |
| 15 | + }; |
| 16 | + |
| 17 | + var patternlab = { |
| 18 | + "listitems": { |
| 19 | + "1": [ |
| 20 | + { |
| 21 | + "title": "Foo" |
| 22 | + } |
| 23 | + ], |
| 24 | + "2": [ |
| 25 | + { |
| 26 | + "title": "Foo" |
| 27 | + }, |
| 28 | + { |
| 29 | + "title": "Bar" |
| 30 | + } |
| 31 | + ] |
| 32 | + }, |
| 33 | + "data": { |
| 34 | + "link": {}, |
| 35 | + "partials": [] |
| 36 | + }, |
| 37 | + "config": {"debug": false} |
| 38 | + }; |
| 39 | + |
| 40 | + var list_item_hunter = new lih(); |
| 41 | + |
| 42 | + //act |
| 43 | + list_item_hunter.process_list_item_partials(currentPattern, patternlab); |
| 44 | + |
| 45 | + //assert |
| 46 | + test.equals(currentPattern.extendedTemplate, "FooBar" ); |
| 47 | + |
| 48 | + test.done(); |
| 49 | + }, |
| 50 | + |
| 51 | + 'process_list_item_partials finds partials and outputs repeated renders' : function(test){ |
| 52 | + //arrange |
| 53 | + //setup current pattern from what we would have during execution |
| 54 | + var currentPattern = { |
| 55 | + "template": "{{#listItems.two}}{{ title }}{{/listItems.two}}", |
| 56 | + "extendedTemplate" : "{{#listItems.two}}{{> test-simple }}{{/listItems.two}}", |
| 57 | + "key": "test-patternName", |
| 58 | + "jsonFileData" : {} |
| 59 | + }; |
| 60 | + |
| 61 | + var patternlab = { |
| 62 | + "listitems": { |
| 63 | + "1": [ |
| 64 | + { |
| 65 | + "title": "Foo" |
| 66 | + } |
| 67 | + ], |
| 68 | + "2": [ |
| 69 | + { |
| 70 | + "title": "Foo" |
| 71 | + }, |
| 72 | + { |
| 73 | + "title": "Bar" |
| 74 | + } |
| 75 | + ] |
| 76 | + }, |
| 77 | + "data": { |
| 78 | + "link": {}, |
| 79 | + "partials": [] |
| 80 | + }, |
| 81 | + "config": {"debug": false}, |
| 82 | + "patterns": [ |
| 83 | + { |
| 84 | + "template": "{{ title }}", |
| 85 | + "extendedTemplate" : "{{ title }}", |
| 86 | + "key": "test-simple", |
| 87 | + "jsonFileData" : {} |
| 88 | + } |
| 89 | + ] |
| 90 | + }; |
| 91 | + |
| 92 | + var list_item_hunter = new lih(); |
| 93 | + |
| 94 | + //act |
| 95 | + list_item_hunter.process_list_item_partials(currentPattern, patternlab); |
| 96 | + |
| 97 | + //assert |
| 98 | + test.equals(currentPattern.extendedTemplate, "FooBar" ); |
| 99 | + |
| 100 | + test.done(); |
| 101 | + }, |
| 102 | + |
| 103 | + //TODO |
| 104 | + //'process_list_item_partials overwrites listItem data if local .listitem.json is found' : function(test){ |
| 105 | + // //arrange |
| 106 | + // //setup current pattern from what we would have during execution |
| 107 | + // var currentPattern = { |
| 108 | + // "template": "{{#listItems.two}}{{ title }}{{/listItems.two}}", |
| 109 | + // "extendedTemplate" : "{{#listItems.two}}{{ title }}{{/listItems.two}}", |
| 110 | + // "key": "test-patternName", |
| 111 | + // "jsonFileData" : {} |
| 112 | + // }; |
| 113 | + |
| 114 | + // var patternlab = { |
| 115 | + // "listitems": { |
| 116 | + // "1": [ |
| 117 | + // { |
| 118 | + // "title": "Foo" |
| 119 | + // } |
| 120 | + // ], |
| 121 | + // "2": [ |
| 122 | + // { |
| 123 | + // "title": "Foo" |
| 124 | + // }, |
| 125 | + // { |
| 126 | + // "title": "Bar" |
| 127 | + // } |
| 128 | + // ] |
| 129 | + // }, |
| 130 | + // "data": { |
| 131 | + // "link": {}, |
| 132 | + // "partials": [] |
| 133 | + // }, |
| 134 | + // "config": {"debug": true} |
| 135 | + // }; |
| 136 | + |
| 137 | + // var list_item_hunter = new lih(); |
| 138 | + |
| 139 | + // //act |
| 140 | + // list_item_hunter.process_list_item_partials(currentPattern, patternlab); |
| 141 | + |
| 142 | + // //assert |
| 143 | + // test.equals(currentPattern.extendedTemplate, "FooBar" ); |
| 144 | + |
| 145 | + // test.done(); |
| 146 | + //}, |
| 147 | + |
| 148 | + }; |
| 149 | + |
| 150 | +}()); |
0 commit comments