Skip to content
This repository was archived by the owner on Feb 25, 2018. It is now read-only.

Commit 707763e

Browse files
committed
Small changes to code style
Mostly re-indentation or similar.
1 parent 2efce21 commit 707763e

4 files changed

Lines changed: 81 additions & 35 deletions

File tree

.jshintrc

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
11
{
2+
"node": true,
3+
"browser": true,
4+
"esnext": true,
5+
"bitwise": true,
26
"curly": true,
37
"eqeqeq": true,
48
"immed": true,
59
"latedef": true,
610
"newcap": true,
711
"noarg": true,
8-
"sub": true,
12+
"regexp": true,
913
"undef": true,
14+
"trailing": true,
15+
"smarttabs": true,
16+
"sub": true,
1017
"boss": true,
1118
"eqnull": true,
12-
"node": true,
13-
"phantom": true
19+
"phantom": true,
20+
21+
"globals": {
22+
"jQuery": true,
23+
"$": true,
24+
"Modernizr": true,
25+
26+
"module": true,
27+
"require": true,
28+
"requirejs": true,
29+
"define": true,
30+
31+
"sinon": true,
32+
"describe": true,
33+
"it": true,
34+
"expect": true,
35+
"beforeEach": true,
36+
"afterEach": true
37+
}
1438
}

Gruntfile.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
/*
22
* grunt-phantomcss
3-
* https://github.com/chrisgladd/grunt-phantomcss
3+
* https://github.com/anselmh/grunt-phantomcss
44
*
55
* Copyright (c) 2013 Chris Gladd
6+
* Copyright (c) since 2014 Anselm Hannemann
7+
*
68
* Licensed under the MIT license.
79
*/
810

911
'use strict';
10-
module.exports = function(grunt) {
12+
13+
module.exports = function (grunt) {
1114
// Project configuration.
1215
grunt.initConfig({
1316
jshint: {
@@ -22,7 +25,7 @@ module.exports = function(grunt) {
2225
},
2326
},
2427

25-
// Before generating any new files, remove any
28+
// Before generating any new files, remove any
2629
// previously-created files.
2730
clean: {
2831
tests: ['tmp'],

phantomjs/runner.js

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,80 @@
1+
/*
2+
* grunt-phantomcss
3+
* https://github.com/anselmh/grunt-phantomcss
4+
*
5+
* Copyright (c) 2013 Chris Gladd
6+
* Copyright (c) since 2014 Anselm Hannemann
7+
*
8+
* Licensed under the MIT license.
9+
*/
10+
11+
'use-strict';
12+
13+
// Get node fileSystem module and define the separator module
114
var fs = require('fs');
215
var s = fs.separator;
316

417
// Parse arguments passed in from the grunt task
518
var args = JSON.parse(phantom.args[0]);
619

20+
// Get viewport arguments (width | height)
721
var viewportSize = {
8-
width: args.viewportSize[0],
9-
height: args.viewportSize[1]
22+
width: args.viewportSize[0],
23+
height: args.viewportSize[1]
1024
};
1125

1226
// Messages are sent to the parent by appending them to the tempfile
1327
var sendMessage = function() {
14-
fs.write(args.tempFile, JSON.stringify(Array.prototype.slice.call(arguments)) + '\n', 'a');
28+
fs.write(args.tempFile, JSON.stringify(Array.prototype.slice.call(arguments)) + '\n', 'a');
1529
};
1630

1731
// Initialise CasperJs
1832
var phantomCSSPath = args.phantomCSSPath;
33+
1934
phantom.casperPath = phantomCSSPath+s+'CasperJs';
2035
phantom.injectJs(phantom.casperPath+s+'bin'+s+'bootstrap.js');
2136

2237
var casper = require('casper').create({
23-
viewportSize: viewportSize,
24-
logLevel: args.logLevel,
25-
verbose: true
38+
viewportSize: viewportSize,
39+
logLevel: args.logLevel,
40+
verbose: true
2641
});
2742

2843
// Require and initialise PhantomCSS module
2944
var phantomcss = require(phantomCSSPath+s+'phantomcss.js');
3045

3146
phantomcss.init({
32-
screenshotRoot: args.screenshots,
33-
failedComparisonsRoot: args.failures,
34-
libraryRoot: phantomCSSPath, // Give absolute path, otherwise PhantomCSS fails
35-
mismatchTolerance: args.mismatchTolerance,
47+
screenshotRoot: args.screenshots,
48+
failedComparisonsRoot: args.failures,
49+
libraryRoot: phantomCSSPath, // Give absolute path, otherwise PhantomCSS fails
50+
mismatchTolerance: args.mismatchTolerance, // defaults to 0.05
3651

37-
onFail: function(test) {
38-
sendMessage('onFail', test);
39-
},
40-
onPass: function(test) {
41-
sendMessage('onPass', test);
42-
},
43-
onTimeout: function(test) {
44-
sendMessage('onTimeout', test);
45-
},
46-
onComplete: function(allTests, noOfFails, noOfErrors) {
47-
sendMessage('onComplete', allTests, noOfFails, noOfErrors);
48-
}
52+
onFail: function(test) {
53+
sendMessage('onFail', test);
54+
},
55+
onPass: function(test) {
56+
sendMessage('onPass', test);
57+
},
58+
onTimeout: function(test) {
59+
sendMessage('onTimeout', test);
60+
},
61+
onComplete: function(allTests, noOfFails, noOfErrors) {
62+
sendMessage('onComplete', allTests, noOfFails, noOfErrors);
63+
}
4964
});
5065

5166
// Run the test scenarios
5267
args.test.forEach(function(testSuite) {
53-
require(testSuite);
68+
require(testSuite);
5469
});
5570

5671
// End tests and compare screenshots
5772
casper.then(function() {
58-
phantomcss.compareAll();
73+
phantomcss.compareAll();
5974
})
6075
.then(function() {
61-
casper.test.done();
76+
casper.test.done();
6277
})
6378
.run(function() {
64-
phantom.exit();
79+
phantom.exit();
6580
});

tasks/phantomcss.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
/**
1+
/*
22
* grunt-phantomcss
3-
* https://github.com/chrisgladd/grunt-phantomcss
3+
* https://github.com/anselmh/grunt-phantomcss
44
*
55
* Copyright (c) 2013 Chris Gladd
6+
* Copyright (c) since 2014 Anselm Hannemann
7+
*
68
* Licensed under the MIT license.
79
*/
10+
811
'use strict';
912

1013
var path = require('path');
@@ -17,12 +20,13 @@ module.exports = function(grunt) {
1720
grunt.registerMultiTask('phantomcss', 'CSS Regression Testing', function() {
1821
var done = this.async();
1922

23+
// Variable object to set default values for options
2024
var options = this.options({
2125
screenshots: 'screenshots',
2226
results: 'results',
2327
viewportSize: [1280, 800],
2428
mismatchTolerance: 0.05,
25-
logLevel: 'error'
29+
logLevel: 'error' // notice | warn | error
2630
});
2731

2832
// Timeout ID for message checking loop

0 commit comments

Comments
 (0)