Skip to content

Commit 5ed2449

Browse files
committed
closes #515
1 parent eefa2d3 commit 5ed2449

File tree

1 file changed

+85
-82
lines changed

1 file changed

+85
-82
lines changed

test/style_modifier_hunter_tests.js

Lines changed: 85 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,89 @@
11
"use strict";
22

3+
var tap = require('tap');
4+
35
var smh = require('../core/lib/style_modifier_hunter');
46

5-
exports['consume_style_modifier'] = {
6-
'uses the partial stylemodifer to modify the patterns extendedTemplate' : function(test){
7-
//arrange
8-
var pl = {};
9-
pl.partials = {};
10-
pl.config = {};
11-
pl.config.debug = false;
12-
13-
var pattern = {
14-
extendedTemplate: '<div class="foo {{styleModifier}}"></div>'
15-
};
16-
17-
var style_modifier_hunter = new smh();
18-
19-
//act
20-
style_modifier_hunter.consume_style_modifier(pattern, '{{> partial:bar}}', pl);
21-
22-
//assert
23-
test.equals(pattern.extendedTemplate, '<div class="foo bar"></div>');
24-
test.done();
25-
},
26-
'replaces style modifiers with spaces in the syntax' : function(test){
27-
//arrange
28-
var pl = {};
29-
pl.partials = {};
30-
pl.config = {};
31-
pl.config.debug = false;
32-
33-
var pattern = {
34-
extendedTemplate: '<div class="foo {{ styleModifier }}"></div>'
35-
};
36-
37-
var style_modifier_hunter = new smh();
38-
39-
//act
40-
style_modifier_hunter.consume_style_modifier(pattern, '{{> partial:bar}}', pl);
41-
42-
//assert
43-
test.equals(pattern.extendedTemplate, '<div class="foo bar"></div>');
44-
test.done();
45-
},
46-
'replaces multiple style modifiers' : function(test){
47-
//arrange
48-
var pl = {};
49-
pl.partials = {};
50-
pl.config = {};
51-
pl.config.debug = false;
52-
53-
var pattern = {
54-
extendedTemplate: '<div class="foo {{ styleModifier }}"></div>'
55-
};
56-
57-
var style_modifier_hunter = new smh();
58-
59-
//act
60-
style_modifier_hunter.consume_style_modifier(pattern, '{{> partial:bar|baz|dum}}', pl);
61-
62-
//assert
63-
test.equals(pattern.extendedTemplate, '<div class="foo bar baz dum"></div>');
64-
test.done();
65-
},
66-
'does not alter pattern extendedTemplate if styleModifier not found in partial' : function(test){
67-
//arrange
68-
var pl = {};
69-
pl.partials = {};
70-
pl.config = {};
71-
pl.config.debug = false;
72-
73-
var pattern = {
74-
extendedTemplate: '<div class="foo {{styleModifier}}"></div>'
75-
};
76-
77-
var style_modifier_hunter = new smh();
78-
79-
//act
80-
style_modifier_hunter.consume_style_modifier(pattern, '{{> partial}}', pl);
81-
82-
//assert
83-
test.equals(pattern.extendedTemplate, '<div class="foo {{styleModifier}}"></div>');
84-
test.done();
85-
}
86-
};
7+
tap.test('uses the partial stylemodifer to modify the patterns extendedTemplate', function(test){
8+
//arrange
9+
var pl = {};
10+
pl.partials = {};
11+
pl.config = {};
12+
pl.config.debug = false;
13+
14+
var pattern = {
15+
extendedTemplate: '<div class="foo {{styleModifier}}"></div>'
16+
};
17+
18+
var style_modifier_hunter = new smh();
19+
20+
//act
21+
style_modifier_hunter.consume_style_modifier(pattern, '{{> partial:bar}}', pl);
22+
23+
//assert
24+
test.equals(pattern.extendedTemplate, '<div class="foo bar"></div>');
25+
test.end();
26+
});
27+
28+
tap.test('replaces style modifiers with spaces in the syntax', function(test){
29+
//arrange
30+
var pl = {};
31+
pl.partials = {};
32+
pl.config = {};
33+
pl.config.debug = false;
34+
35+
var pattern = {
36+
extendedTemplate: '<div class="foo {{ styleModifier }}"></div>'
37+
};
38+
39+
var style_modifier_hunter = new smh();
40+
41+
//act
42+
style_modifier_hunter.consume_style_modifier(pattern, '{{> partial:bar}}', pl);
43+
44+
//assert
45+
test.equals(pattern.extendedTemplate, '<div class="foo bar"></div>');
46+
test.end();
47+
});
48+
49+
tap.test('replaces multiple style modifiers', function(test){
50+
//arrange
51+
var pl = {};
52+
pl.partials = {};
53+
pl.config = {};
54+
pl.config.debug = false;
55+
56+
var pattern = {
57+
extendedTemplate: '<div class="foo {{ styleModifier }}"></div>'
58+
};
59+
60+
var style_modifier_hunter = new smh();
61+
62+
//act
63+
style_modifier_hunter.consume_style_modifier(pattern, '{{> partial:bar|baz|dum}}', pl);
64+
65+
//assert
66+
test.equals(pattern.extendedTemplate, '<div class="foo bar baz dum"></div>');
67+
test.end();
68+
});
69+
70+
tap.test('does not alter pattern extendedTemplate if styleModifier not found in partial', function(test){
71+
//arrange
72+
var pl = {};
73+
pl.partials = {};
74+
pl.config = {};
75+
pl.config.debug = false;
76+
77+
var pattern = {
78+
extendedTemplate: '<div class="foo {{styleModifier}}"></div>'
79+
};
80+
81+
var style_modifier_hunter = new smh();
82+
83+
//act
84+
style_modifier_hunter.consume_style_modifier(pattern, '{{> partial}}', pl);
85+
86+
//assert
87+
test.equals(pattern.extendedTemplate, '<div class="foo {{styleModifier}}"></div>');
88+
test.end();
89+
});

0 commit comments

Comments
 (0)