Skip to content

Commit f115aa9

Browse files
committed
Convert engine_mustache_tests.js to use tape
1 parent 1df0dca commit f115aa9

File tree

1 file changed

+115
-109
lines changed

1 file changed

+115
-109
lines changed

test/engine_mustache_tests.js

Lines changed: 115 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
"use strict";
2+
/*eslint-disable no-shadow*/
23

4+
var test = require('tape');
35
var path = require('path');
46
var pa = require('../core/lib/pattern_assembler');
57
var Pattern = require('../core/lib/object_factory').Pattern;
68
var testPatternsPath = path.resolve(__dirname, 'files', '_patterns');
79
var eol = require('os').EOL;
810

11+
// don't run these tests unless mustache is installed
12+
var engineLoader = require('../core/lib/pattern_engines');
13+
if (!engineLoader.mustache) {
14+
test.only('Mustache engine not installed, skipping tests.', function (test) {
15+
test.end();
16+
});
17+
}
18+
919
// fake pattern lab constructor:
1020
// sets up a fake patternlab object, which is needed by the pattern processing
1121
// apparatus.
@@ -33,7 +43,7 @@ function fakePatternLab() {
3343

3444
// function for testing sets of partials
3545
function testFindPartials(test, partialTests) {
36-
test.expect(partialTests.length + 1);
46+
test.plan(partialTests.length + 1);
3747

3848
// setup current pattern from what we would have during execution
3949
// docs on partial syntax are here:
@@ -55,11 +65,11 @@ function testFindPartials(test, partialTests) {
5565
test.equals(results[index], testString);
5666
});
5767

58-
test.done();
68+
test.end();
5969
}
6070

6171
function testFindPartialsWithStyleModifiers(test, partialTests) {
62-
test.expect(partialTests.length + 1);
72+
test.plan(partialTests.length + 1);
6373

6474
// setup current pattern from what we would have during execution
6575
// docs on partial syntax are here:
@@ -81,11 +91,11 @@ function testFindPartialsWithStyleModifiers(test, partialTests) {
8191
test.equals(results[index], testString);
8292
});
8393

84-
test.done();
94+
test.end();
8595
}
8696

8797
function testFindPartialsWithPatternParameters(test, partialTests) {
88-
test.expect(partialTests.length + 1);
98+
test.plan(partialTests.length + 1);
8999

90100
// setup current pattern from what we would have during execution
91101
// docs on partial syntax are here:
@@ -107,110 +117,106 @@ function testFindPartialsWithPatternParameters(test, partialTests) {
107117
test.equals(results[index], testString);
108118
});
109119

110-
test.done();
120+
test.end();
111121
}
112122

113-
exports['engine_mustache'] = {
114-
'find_pattern_partials finds one simple partial': function (test) {
115-
testFindPartials(test, [
116-
"{{> molecules-comment-header}}"
117-
]);
118-
},
119-
120-
'find_pattern_partials finds simple partials under stressed circumstances': function (test) {
121-
testFindPartials(test, [
122-
"{{>molecules-comment-header}}",
123-
"{{> " + eol + " molecules-comment-header" + eol + "}}",
124-
"{{> molecules-weird-spacing }}"
125-
]);
126-
},
127-
128-
'find_pattern_partials finds one simple verbose partial': function (test) {
129-
testFindPartials(test, [
130-
'{{> 00-atoms/00-global/06-test }}'
131-
]);
132-
},
133-
134-
'find_pattern_partials finds partials with parameters': function (test) {
135-
testFindPartials(test, [
136-
"{{> molecules-single-comment(description: true) }}",
137-
"{{> molecules-single-comment(description: 42) }}",
138-
"{{> molecules-single-comment(description: '42') }}",
139-
"{{> molecules-single-comment(description: \"42\") }}",
140-
"{{> molecules-single-comment(description: 'test', anotherThing: 'retest') }}",
141-
"{{> molecules-single-comment(description: false, anotherThing: \"retest\") }}",
142-
'{{> molecules-single-comment(description:"A life is like a \"garden\". Perfect moments can be had, but not preserved, except in memory.") }}'
143-
]);
144-
},
145-
146-
'find_pattern_partials finds simple partials with style modifiers': function (test) {
147-
testFindPartials(test, [
148-
'{{> molecules-single-comment:foo }}',
149-
'{{> molecules-single-comment:foo|bar }}'
150-
]);
151-
},
152-
'find_pattern_partials finds mixed partials': function (test) {
153-
testFindPartials(test, [
154-
'{{> molecules-single-comment:foo(description: "test", anotherThing: true) }}',
155-
'{{> molecules-single-comment:foo|bar(description: true) }}'
156-
]);
157-
},
158-
159-
'find_pattern_partials finds one simple partial with styleModifier': function (test) {
160-
testFindPartialsWithStyleModifiers(test, [
161-
"{{> molecules-comment-header:test}}"
162-
]);
163-
},
164-
'find_pattern_partials finds partial with many styleModifiers': function (test) {
165-
testFindPartialsWithStyleModifiers(test, [
166-
"{{> molecules-comment-header:test|test2|test3}}"
167-
]);
168-
},
169-
'find_pattern_partials finds partials with differing styleModifiers': function (test) {
170-
testFindPartialsWithStyleModifiers(test, [
171-
"{{> molecules-comment-header:test|test2|test3}}",
172-
"{{> molecules-comment-header:foo-1}}",
173-
"{{> molecules-comment-header:bar_1}}"
174-
]);
175-
},
176-
'find_pattern_partials finds partials with styleModifiers when parameters present': function (test) {
177-
testFindPartialsWithStyleModifiers(test, [
178-
"{{> molecules-comment-header:test|test2|test3(description: true)}}",
179-
"{{> molecules-comment-header:foo-1(description: 'foo')}}",
180-
"{{> molecules-comment-header:bar_1(descrition: 'bar', anotherThing: 10102010) }}"
181-
]);
182-
},
183-
184-
'find_pattern_partials_with_parameters finds one simple partial with parameters': function (test) {
185-
testFindPartialsWithPatternParameters(test, [
186-
"{{> molecules-comment-header(description: 'test')}}"
187-
]);
188-
},
189-
'find_pattern_partials_with_parameters finds partials with parameters': function (test) {
190-
testFindPartialsWithPatternParameters(test, [
191-
"{{> molecules-single-comment(description: true) }}",
192-
"{{> molecules-single-comment(description: 42) }}",
193-
"{{> molecules-single-comment(description: '42') }}",
194-
"{{> molecules-single-comment(description: \"42\") }}",
195-
"{{> molecules-single-comment(description: 'test', anotherThing: 'retest') }}",
196-
"{{> molecules-single-comment(description: false, anotherThing: \"retest\") }}",
197-
'{{> molecules-single-comment(description:"A life is like a \"garden\". Perfect moments can be had, but not preserved, except in memory.") }}'
198-
]);
199-
},
200-
'find_pattern_partials finds partials with parameters when styleModifiers present': function (test) {
201-
testFindPartialsWithPatternParameters(test, [
202-
"{{> molecules-comment-header:test|test2|test3(description: true)}}",
203-
"{{> molecules-comment-header:foo-1(description: 'foo')}}",
204-
"{{> molecules-comment-header:bar_1(descrition: 'bar', anotherThing: 10102010) }}"
205-
]);
206-
}
207-
208-
};
209123

210-
211-
// don't run these tests unless mustache is installed
212-
var engineLoader = require('../core/lib/pattern_engines');
213-
if (!engineLoader.mustache) {
214-
console.log("Mustache engine not installed, skipping tests.");
215-
delete exports.engine_mustache;
216-
}
124+
test('find_pattern_partials finds one simple partial', function (test) {
125+
testFindPartials(test, [
126+
"{{> molecules-comment-header}}"
127+
]);
128+
});
129+
130+
test('find_pattern_partials finds simple partials under stressed circumstances', function (test) {
131+
testFindPartials(test, [
132+
"{{>molecules-comment-header}}",
133+
"{{> " + eol + " molecules-comment-header" + eol + "}}",
134+
"{{> molecules-weird-spacing }}"
135+
]);
136+
});
137+
138+
test('find_pattern_partials finds one simple verbose partial', function (test) {
139+
testFindPartials(test, [
140+
'{{> 00-atoms/00-global/06-test }}'
141+
]);
142+
});
143+
144+
test('find_pattern_partials finds partials with parameters', function (test) {
145+
testFindPartials(test, [
146+
"{{> molecules-single-comment(description: true) }}",
147+
"{{> molecules-single-comment(description: 42) }}",
148+
"{{> molecules-single-comment(description: '42') }}",
149+
"{{> molecules-single-comment(description: \"42\") }}",
150+
"{{> molecules-single-comment(description: 'test', anotherThing: 'retest') }}",
151+
"{{> molecules-single-comment(description: false, anotherThing: \"retest\") }}",
152+
'{{> molecules-single-comment(description:"A life is like a \"garden\". Perfect moments can be had, but not preserved, except in memory.") }}'
153+
]);
154+
});
155+
156+
test('find_pattern_partials finds simple partials with style modifiers', function (test) {
157+
testFindPartials(test, [
158+
'{{> molecules-single-comment:foo }}',
159+
'{{> molecules-single-comment:foo|bar }}'
160+
]);
161+
});
162+
163+
test('find_pattern_partials finds mixed partials', function (test) {
164+
testFindPartials(test, [
165+
'{{> molecules-single-comment:foo(description: "test", anotherThing: true) }}',
166+
'{{> molecules-single-comment:foo|bar(description: true) }}'
167+
]);
168+
});
169+
170+
test('find_pattern_partials finds one simple partial with styleModifier', function (test) {
171+
testFindPartialsWithStyleModifiers(test, [
172+
"{{> molecules-comment-header:test}}"
173+
]);
174+
});
175+
176+
test('find_pattern_partials finds partial with many styleModifiers', function (test) {
177+
testFindPartialsWithStyleModifiers(test, [
178+
"{{> molecules-comment-header:test|test2|test3}}"
179+
]);
180+
});
181+
182+
test('find_pattern_partials finds partials with differing styleModifiers', function (test) {
183+
testFindPartialsWithStyleModifiers(test, [
184+
"{{> molecules-comment-header:test|test2|test3}}",
185+
"{{> molecules-comment-header:foo-1}}",
186+
"{{> molecules-comment-header:bar_1}}"
187+
]);
188+
});
189+
190+
test('find_pattern_partials finds partials with styleModifiers when parameters present', function (test) {
191+
testFindPartialsWithStyleModifiers(test, [
192+
"{{> molecules-comment-header:test|test2|test3(description: true)}}",
193+
"{{> molecules-comment-header:foo-1(description: 'foo')}}",
194+
"{{> molecules-comment-header:bar_1(descrition: 'bar', anotherThing: 10102010) }}"
195+
]);
196+
});
197+
198+
test('find_pattern_partials_with_parameters finds one simple partial with parameters', function (test) {
199+
testFindPartialsWithPatternParameters(test, [
200+
"{{> molecules-comment-header(description: 'test')}}"
201+
]);
202+
});
203+
204+
test('find_pattern_partials_with_parameters finds partials with parameters', function (test) {
205+
testFindPartialsWithPatternParameters(test, [
206+
"{{> molecules-single-comment(description: true) }}",
207+
"{{> molecules-single-comment(description: 42) }}",
208+
"{{> molecules-single-comment(description: '42') }}",
209+
"{{> molecules-single-comment(description: \"42\") }}",
210+
"{{> molecules-single-comment(description: 'test', anotherThing: 'retest') }}",
211+
"{{> molecules-single-comment(description: false, anotherThing: \"retest\") }}",
212+
'{{> molecules-single-comment(description:"A life is like a \"garden\". Perfect moments can be had, but not preserved, except in memory.") }}'
213+
]);
214+
});
215+
216+
test('find_pattern_partials finds partials with parameters when styleModifiers present', function (test) {
217+
testFindPartialsWithPatternParameters(test, [
218+
"{{> molecules-comment-header:test|test2|test3(description: true)}}",
219+
"{{> molecules-comment-header:foo-1(description: 'foo')}}",
220+
"{{> molecules-comment-header:bar_1(descrition: 'bar', anotherThing: 10102010) }}"
221+
]);
222+
});

0 commit comments

Comments
 (0)