Skip to content

Commit 3b75ba2

Browse files
committed
Pulling the differ module out into something that can be configured
1 parent 52e863f commit 3b75ba2

4 files changed

Lines changed: 19 additions & 11 deletions

File tree

server/checkBuild.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ var assert = require('chai').assert;
44
var Bluebird = require('bluebird');
55
var dispatcher = require('./dispatcher');
66
var storage = require('./utils/storage');
7-
var differ = require('./utils/differ');
87
var constants = require('./constants');
98
var actions = require('./actions');
109

@@ -264,6 +263,8 @@ function diffImage(options) {
264263
})
265264
])
266265
.spread(function(headImage, baseImage) {
266+
var differ = config.getDiffer();
267+
267268
return differ.generateDiff(headImage, baseImage)
268269
.then(function(data) {
269270

server/configuration.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ var defaults = {
66
url: 'http://visualdiff.ngrok.com',
77
ip: '0.0.0.0',
88
port: 8999,
9-
service: undefined
9+
service: undefined,
10+
differ: undefined
1011
};
1112

1213
function Configuration() {
@@ -32,8 +33,11 @@ Configuration.prototype = {
3233

3334
getUrl: function() {
3435
return this._config.host;
35-
}
36+
},
3637

38+
getDiffer: function() {
39+
return this._config.differ;
40+
}
3741
};
3842

3943
module.exports = Configuration;

test/checkBuild-test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ var Configuration = require('../server/configuration');
1010
describe('module/checkBuild', function() {
1111
var dispatcherStub;
1212
var storageStub;
13-
var differStub;
1413
var actionsStub;
1514

1615
var checkBuild;
@@ -27,10 +26,6 @@ describe('module/checkBuild', function() {
2726
})
2827
};
2928

30-
differStub = {
31-
'@noCallThru': true
32-
};
33-
3429
dispatcherStub = {
3530
'@noCallThru': true,
3631
on: this.sinon.spy()
@@ -44,7 +39,6 @@ describe('module/checkBuild', function() {
4439

4540
var CheckBuild = proxyquire('../server/checkBuild', {
4641
'./utils/storage': storageStub,
47-
'./utils/differ': differStub,
4842
'./dispatcher': dispatcherStub,
4943
'./actions': actionsStub
5044
});
@@ -614,6 +608,7 @@ describe('module/checkBuild', function() {
614608
});
615609

616610
describe('#diffImage', function() {
611+
var differStub;
617612
var generateDiffStub;
618613
var options;
619614

@@ -633,7 +628,12 @@ describe('module/checkBuild', function() {
633628
width: 200
634629
});
635630

636-
differStub.generateDiff = generateDiffStub;
631+
differStub = {
632+
'@noCallThru': true,
633+
generateDiff: generateDiffStub
634+
};
635+
636+
config.getDiffer = this.sinon.stub().returns(differStub);
637637

638638
storageStub.getImage = this.sinon.stub();
639639
});

visualtesting.conf.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
var Github = require('./server/utils/github');
4+
var Differ = require('./server/utils/differ');
45

56
var service;
67

@@ -14,7 +15,9 @@ function Apply(config) {
1415
config.set({
1516
port: 9000,
1617

17-
service: service
18+
service: service,
19+
20+
differ: Differ
1821
});
1922
}
2023

0 commit comments

Comments
 (0)