Skip to content

Commit 95a5e63

Browse files
committed
refactor(unit tests): Run tests through prettier
1 parent 7cad1f1 commit 95a5e63

31 files changed

+4214
-2950
lines changed

test/addPattern_tests.js

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"use strict";
1+
'use strict';
22

33
const tap = require('tap');
44

@@ -8,38 +8,44 @@ const util = require('./util/test_utils.js');
88

99
const patterns_dir = './test/files/_patterns';
1010

11-
tap.test('addPattern - adds pattern extended template to patternlab partial object', function (test) {
12-
//arrange
13-
const patternlab = util.fakePatternLab(patterns_dir);
14-
15-
var pattern = new Pattern('00-test/01-bar.mustache');
16-
pattern.extendedTemplate = 'barExtended';
17-
pattern.template = 'bar';
18-
19-
//act
20-
addPattern(pattern, patternlab);
21-
22-
//assert
23-
test.equals(patternlab.patterns.length, 1);
24-
test.equals(patternlab.partials['test-bar'] !== undefined, true);
25-
test.equals(patternlab.partials['test-bar'], 'barExtended');
26-
test.end();
27-
});
28-
29-
tap.test('addPattern - adds pattern template to patternlab partial object if extendedtemplate does not exist yet', function (test){
30-
//arrange
31-
const patternlab = util.fakePatternLab(patterns_dir);
32-
33-
var pattern = new Pattern('00-test/01-bar.mustache');
34-
pattern.extendedTemplate = undefined;
35-
pattern.template = 'bar';
36-
37-
//act
38-
addPattern(pattern, patternlab);
39-
40-
//assert
41-
test.equals(patternlab.patterns.length, 1);
42-
test.equals(patternlab.partials['test-bar'] !== undefined, true);
43-
test.equals(patternlab.partials['test-bar'], 'bar');
44-
test.end();
45-
});
11+
tap.test(
12+
'addPattern - adds pattern extended template to patternlab partial object',
13+
function(test) {
14+
//arrange
15+
const patternlab = util.fakePatternLab(patterns_dir);
16+
17+
var pattern = new Pattern('00-test/01-bar.mustache');
18+
pattern.extendedTemplate = 'barExtended';
19+
pattern.template = 'bar';
20+
21+
//act
22+
addPattern(pattern, patternlab);
23+
24+
//assert
25+
test.equals(patternlab.patterns.length, 1);
26+
test.equals(patternlab.partials['test-bar'] !== undefined, true);
27+
test.equals(patternlab.partials['test-bar'], 'barExtended');
28+
test.end();
29+
}
30+
);
31+
32+
tap.test(
33+
'addPattern - adds pattern template to patternlab partial object if extendedtemplate does not exist yet',
34+
function(test) {
35+
//arrange
36+
const patternlab = util.fakePatternLab(patterns_dir);
37+
38+
var pattern = new Pattern('00-test/01-bar.mustache');
39+
pattern.extendedTemplate = undefined;
40+
pattern.template = 'bar';
41+
42+
//act
43+
addPattern(pattern, patternlab);
44+
45+
//assert
46+
test.equals(patternlab.patterns.length, 1);
47+
test.equals(patternlab.partials['test-bar'] !== undefined, true);
48+
test.equals(patternlab.partials['test-bar'], 'bar');
49+
test.end();
50+
}
51+
);

test/annotation_exporter_tests.js

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"use strict";
1+
'use strict';
22

33
var tap = require('tap');
44

@@ -7,13 +7,13 @@ var anPath = './test/files/';
77

88
function createFakePatternLab(anPath, customProps) {
99
var pl = {
10-
"config": {
11-
"paths": {
12-
"source": {
13-
"annotations": anPath
14-
}
15-
}
16-
}
10+
config: {
11+
paths: {
12+
source: {
13+
annotations: anPath,
14+
},
15+
},
16+
},
1717
};
1818

1919
return extend(pl, customProps);
@@ -22,7 +22,7 @@ function createFakePatternLab(anPath, customProps) {
2222
var patternlab = createFakePatternLab(anPath);
2323
var ae = require('../core/lib/annotation_exporter')(patternlab);
2424

25-
tap.test('converts old JS annotations into new format', function (test) {
25+
tap.test('converts old JS annotations into new format', function(test) {
2626
//arrange
2727
//act
2828
var annotations = ae.gatherJS();
@@ -31,12 +31,15 @@ tap.test('converts old JS annotations into new format', function (test) {
3131
test.equals(annotations.length, 2);
3232
test.equals(annotations[1].el, '.logo');
3333
test.equals(annotations[1].title, 'Logo');
34-
test.equals(annotations[1].comment, "The logo image is an SVG file, which ensures that the logo displays crisply even on high resolution displays. A PNG fallback is provided for browsers that don't support SVG images.</p><p>Further reading: <a href=\"http://bradfrostweb.com/blog/mobile/hi-res-optimization/\">Optimizing Web Experiences for High Resolution Screens</a></p>");
34+
test.equals(
35+
annotations[1].comment,
36+
'The logo image is an SVG file, which ensures that the logo displays crisply even on high resolution displays. A PNG fallback is provided for browsers that don\'t support SVG images.</p><p>Further reading: <a href="http://bradfrostweb.com/blog/mobile/hi-res-optimization/">Optimizing Web Experiences for High Resolution Screens</a></p>'
37+
);
3538

3639
test.end();
3740
});
3841

39-
tap.test('converts new markdown annotations into an array', function (test) {
42+
tap.test('converts new markdown annotations into an array', function(test) {
4043
//arrange
4144
//act
4245
var annotations = ae.gatherMD();
@@ -45,12 +48,15 @@ tap.test('converts new markdown annotations into an array', function (test) {
4548
test.equals(annotations.length, 3);
4649
test.equals(annotations[1].el, '.logo');
4750
test.equals(annotations[1].title, 'Logo');
48-
test.equals(annotations[1].comment.replace(/\r?\n|\r/gm, ""), '<p>The <em>logo image</em> is an SVG file.</p>');
51+
test.equals(
52+
annotations[1].comment.replace(/\r?\n|\r/gm, ''),
53+
'<p>The <em>logo image</em> is an SVG file.</p>'
54+
);
4955

5056
test.end();
5157
});
5258

53-
tap.test('merges both annotation methods into one array', function (test) {
59+
tap.test('merges both annotation methods into one array', function(test) {
5460
//arrange
5561

5662
//act
@@ -60,12 +66,15 @@ tap.test('merges both annotation methods into one array', function (test) {
6066
test.equals(annotations.length, 3);
6167
test.equals(annotations[2].el, '#nav');
6268
test.equals(annotations[2].title, 'Navigation');
63-
test.equals(annotations[2].comment.replace(/\r?\n|\r/gm, ""), '<p>Navigation for adaptive web experiences can be tricky. Refer to <a href="https://bradfrost.github.io/this-is-responsive/patterns.html#navigation">these repsonsive patterns</a> when evaluating solutions.</p>');
69+
test.equals(
70+
annotations[2].comment.replace(/\r?\n|\r/gm, ''),
71+
'<p>Navigation for adaptive web experiences can be tricky. Refer to <a href="https://bradfrost.github.io/this-is-responsive/patterns.html#navigation">these repsonsive patterns</a> when evaluating solutions.</p>'
72+
);
6473

6574
test.end();
6675
});
6776

68-
tap.test('when there are 0 annotation files', function (test) {
77+
tap.test('when there are 0 annotation files', function(test) {
6978
var emptyAnPath = './test/files/empty/';
7079
var patternlab2 = createFakePatternLab(emptyAnPath);
7180
var ae2 = require('../core/lib/annotation_exporter')(patternlab2);

test/asset_copy_tests.js

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
"use strict";
1+
'use strict';
22

33
var tap = require('tap');
4-
var rewire = require("rewire");
4+
var rewire = require('rewire');
55
var _ = require('lodash');
66
var eol = require('os').EOL;
77
var Pattern = require('../core/lib/object_factory').Pattern;
@@ -30,37 +30,40 @@ function createFakePatternLab(customProps) {
3030
paths: {
3131
source: {
3232
img: './test/img',
33-
css: './test/css'
33+
css: './test/css',
3434
},
3535
public: {
3636
img: './test/output/img',
37-
css: './test/output/css'
38-
}
37+
css: './test/output/css',
38+
},
3939
},
40-
styleGuideExcludes: [ ],
40+
styleGuideExcludes: [],
4141
logLevel: 'quiet',
4242
outputFileSuffixes: {
4343
rendered: '.rendered',
4444
rawTemplate: '',
45-
markupOnly: '.markup-only'
46-
}
45+
markupOnly: '.markup-only',
46+
},
4747
},
48-
data: {}
48+
data: {},
4949
};
5050
return extend(pl, customProps);
5151
}
5252

53-
tap.test('transformConfigPaths takes configuration.paths() and maps to a better key store', function (test) {
54-
//arrange
55-
var patternlab = createFakePatternLab({});
53+
tap.test(
54+
'transformConfigPaths takes configuration.paths() and maps to a better key store',
55+
function(test) {
56+
//arrange
57+
var patternlab = createFakePatternLab({});
5658

57-
//act
58-
var result = assetCopier.transformConfigPaths(patternlab.config.paths);
59+
//act
60+
var result = assetCopier.transformConfigPaths(patternlab.config.paths);
5961

60-
//assert
61-
test.equals(result.img.source, './test/img');
62-
test.equals(result.img.public, './test/output/img');
63-
test.equals(result.css.source, './test/css');
64-
test.equals(result.css.public, './test/output/css');
65-
test.end();
66-
});
62+
//assert
63+
test.equals(result.img.source, './test/img');
64+
test.equals(result.img.public, './test/output/img');
65+
test.equals(result.css.source, './test/css');
66+
test.equals(result.css.public, './test/output/css');
67+
test.end();
68+
}
69+
);

test/data_loader_tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const tap = require('tap');
44

5-
tap.test('loadDataFromFile - Load ', function(test){
5+
tap.test('loadDataFromFile - Load ', function(test) {
66
const fs = require('fs-extra'),
77
dataLoader = require('../core/lib/data_loader')(),
88
data_dir = './test/files/_data/';

0 commit comments

Comments
 (0)