Skip to content

Commit 1df0dca

Browse files
Merge pull request #508 from /issues/507-convert-test
Convert object_factory_tests.js to use tap/tape
2 parents c49ae93 + 8b9ec6f commit 1df0dca

File tree

1 file changed

+72
-68
lines changed

1 file changed

+72
-68
lines changed

test/object_factory_tests.js

+72-68
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"use strict";
22

3+
var tap = require('tap');
4+
35
// fake pattern lab constructor:
46
// sets up a fake patternlab object, which is needed by the pattern processing
57
// apparatus.
@@ -26,76 +28,78 @@ var Pattern = require('../core/lib/object_factory').Pattern;
2628
var path = require('path');
2729
var pl = fakePatternLab();
2830

29-
exports['Pattern initialization'] = {
30-
'test Pattern initializes correctly' : function (test) {
31-
var p = new Pattern('00-atoms/00-global/00-colors.mustache', { d: 123});
32-
test.equals(p.relPath, '00-atoms' + path.sep + '00-global' + path.sep + '00-colors.mustache');
33-
test.equals(p.name, '00-atoms-00-global-00-colors');
34-
test.equals(p.subdir, '00-atoms' + path.sep + '00-global');
35-
test.equals(p.fileName, '00-colors');
36-
test.equals(p.fileExtension, '.mustache');
37-
test.equals(p.jsonFileData.d, 123);
38-
test.equals(p.patternBaseName, 'colors');
39-
test.equals(p.patternName, 'Colors');
40-
test.equals(p.getPatternLink(pl), '00-atoms-00-global-00-colors' + path.sep + '00-atoms-00-global-00-colors.rendered.html');
41-
test.equals(p.patternGroup, 'atoms');
42-
test.equals(p.patternSubGroup, 'global');
43-
test.equals(p.flatPatternPath, '00-atoms-00-global');
44-
test.equals(p.patternPartial, 'atoms-colors');
45-
test.equals(p.template, '');
46-
test.equals(p.patternPartialCode, '');
47-
test.equals(p.lineage.length, 0);
48-
test.equals(p.lineageIndex.length, 0);
49-
test.equals(p.lineageR.length, 0);
50-
test.equals(p.lineageRIndex.length, 0);
51-
test.equals(p.patternState, '');
52-
test.done();
53-
},
54-
'test Pattern with one-directory subdir works as expected' : function (test) {
55-
var p = new Pattern('00-atoms/00-colors.mustache', { d: 123});
56-
test.equals(p.relPath, '00-atoms' + path.sep + '00-colors.mustache');
57-
test.equals(p.name, '00-atoms-00-colors');
58-
test.equals(p.subdir, '00-atoms');
59-
test.equals(p.fileName, '00-colors');
60-
test.equals(p.fileExtension, '.mustache');
61-
test.equals(p.jsonFileData.d, 123);
62-
test.equals(p.patternBaseName, 'colors');
63-
test.equals(p.patternName, 'Colors');
64-
test.equals(p.getPatternLink(pl), '00-atoms-00-colors' + path.sep + '00-atoms-00-colors.rendered.html');
65-
test.equals(p.patternGroup, 'atoms');
66-
test.equals(p.flatPatternPath, '00-atoms');
67-
test.equals(p.patternPartial, 'atoms-colors');
68-
test.equals(p.template, '');
69-
test.equals(p.lineage.length, 0);
70-
test.equals(p.lineageIndex.length, 0);
71-
test.equals(p.lineageR.length, 0);
72-
test.equals(p.lineageRIndex.length, 0);
73-
test.done();
74-
},
75-
'test Pattern with no numbers in pattern group works as expected' : function (test) {
76-
var p = new Pattern('atoms/colors.mustache', { d: 123});
77-
test.equals(p.relPath, 'atoms' + path.sep + 'colors.mustache');
78-
test.equals(p.name, 'atoms-colors');
79-
test.equals(p.subdir, 'atoms');
80-
test.equals(p.fileName, 'colors');
81-
test.equals(p.getPatternLink(pl), 'atoms-colors' + path.sep + 'atoms-colors.rendered.html');
82-
test.equals(p.patternGroup, 'atoms');
83-
test.equals(p.flatPatternPath, 'atoms');
84-
test.equals(p.patternPartial, 'atoms-colors');
85-
test.done();
86-
},
87-
'test Pattern capitalizes patternDisplayName correctly' : function (test) {
88-
var p = new Pattern('00-atoms/00-global/00-colors-alt.mustache', { d: 123});
89-
test.equals(p.patternBaseName, 'colors-alt');
90-
test.equals(p.patternName, 'Colors Alt');
91-
test.done();
92-
},
93-
'The forms of Pattern.getPatternLink() work as expected': function (test) {
31+
tap.test('test Pattern initializes correctly', function (test) {
32+
var p = new Pattern('00-atoms/00-global/00-colors.mustache', { d: 123});
33+
test.equals(p.relPath, '00-atoms' + path.sep + '00-global' + path.sep + '00-colors.mustache');
34+
test.equals(p.name, '00-atoms-00-global-00-colors');
35+
test.equals(p.subdir, '00-atoms' + path.sep + '00-global');
36+
test.equals(p.fileName, '00-colors');
37+
test.equals(p.fileExtension, '.mustache');
38+
test.equals(p.jsonFileData.d, 123);
39+
test.equals(p.patternBaseName, 'colors');
40+
test.equals(p.patternName, 'Colors');
41+
test.equals(p.getPatternLink(pl), '00-atoms-00-global-00-colors' + path.sep + '00-atoms-00-global-00-colors.rendered.html');
42+
test.equals(p.patternGroup, 'atoms');
43+
test.equals(p.patternSubGroup, 'global');
44+
test.equals(p.flatPatternPath, '00-atoms-00-global');
45+
test.equals(p.patternPartial, 'atoms-colors');
46+
test.equals(p.template, '');
47+
test.equals(p.patternPartialCode, '');
48+
test.equals(p.lineage.length, 0);
49+
test.equals(p.lineageIndex.length, 0);
50+
test.equals(p.lineageR.length, 0);
51+
test.equals(p.lineageRIndex.length, 0);
52+
test.equals(p.patternState, '');
53+
test.end();
54+
});
55+
56+
tap.test('test Pattern with one-directory subdir works as expected', function (test) {
57+
var p = new Pattern('00-atoms/00-colors.mustache', { d: 123});
58+
test.equals(p.relPath, '00-atoms' + path.sep + '00-colors.mustache');
59+
test.equals(p.name, '00-atoms-00-colors');
60+
test.equals(p.subdir, '00-atoms');
61+
test.equals(p.fileName, '00-colors');
62+
test.equals(p.fileExtension, '.mustache');
63+
test.equals(p.jsonFileData.d, 123);
64+
test.equals(p.patternBaseName, 'colors');
65+
test.equals(p.patternName, 'Colors');
66+
test.equals(p.getPatternLink(pl), '00-atoms-00-colors' + path.sep + '00-atoms-00-colors.rendered.html');
67+
test.equals(p.patternGroup, 'atoms');
68+
test.equals(p.flatPatternPath, '00-atoms');
69+
test.equals(p.patternPartial, 'atoms-colors');
70+
test.equals(p.template, '');
71+
test.equals(p.lineage.length, 0);
72+
test.equals(p.lineageIndex.length, 0);
73+
test.equals(p.lineageR.length, 0);
74+
test.equals(p.lineageRIndex.length, 0);
75+
test.end();
76+
});
77+
78+
tap.test('test Pattern with no numbers in pattern group works as expected', function (test) {
79+
var p = new Pattern('atoms/colors.mustache', { d: 123});
80+
test.equals(p.relPath, 'atoms' + path.sep + 'colors.mustache');
81+
test.equals(p.name, 'atoms-colors');
82+
test.equals(p.subdir, 'atoms');
83+
test.equals(p.fileName, 'colors');
84+
test.equals(p.getPatternLink(pl), 'atoms-colors' + path.sep + 'atoms-colors.rendered.html');
85+
test.equals(p.patternGroup, 'atoms');
86+
test.equals(p.flatPatternPath, 'atoms');
87+
test.equals(p.patternPartial, 'atoms-colors');
88+
test.end();
89+
});
90+
91+
tap.test('test Pattern capitalizes patternDisplayName correctly', function (test) {
92+
var p = new Pattern('00-atoms/00-global/00-colors-alt.mustache', { d: 123});
93+
test.equals(p.patternBaseName, 'colors-alt');
94+
test.equals(p.patternName, 'Colors Alt');
95+
test.end();
96+
});
97+
98+
tap.test('The forms of Pattern.getPatternLink() work as expected', function (test) {
9499
var p = new Pattern('00-atoms/00-global/00-colors.hbs');
95100
test.equals(p.getPatternLink(pl), '00-atoms-00-global-00-colors' + path.sep + '00-atoms-00-global-00-colors.rendered.html');
96101
test.equals(p.getPatternLink(pl, 'rendered'), '00-atoms-00-global-00-colors' + path.sep + '00-atoms-00-global-00-colors.rendered.html');
97102
test.equals(p.getPatternLink(pl, 'rawTemplate'), '00-atoms-00-global-00-colors' + path.sep + '00-atoms-00-global-00-colors.hbs');
98103
test.equals(p.getPatternLink(pl, 'markupOnly'), '00-atoms-00-global-00-colors' + path.sep + '00-atoms-00-global-00-colors.markup-only.html');
99-
test.done();
100-
}
101-
};
104+
test.end();
105+
});

0 commit comments

Comments
 (0)