|
1 | 1 | var assert = require('assert'); |
2 | 2 | var rewire = require('rewire'); |
| 3 | +var path = require('path'); |
3 | 4 |
|
4 | 5 | var gulpGitFlowDiff = rewire('../'); |
5 | | -gulpGitFlowDiff.__set__({ |
6 | | - process: { |
7 | | - cwd: function() { |
8 | | - return '/home/user/dev' |
9 | | - } |
10 | | - } |
11 | | -}); |
12 | 6 |
|
13 | 7 | describe('gulp-giflow-diff isFileChanged', function() { |
14 | | - process.cwd = function() { |
15 | | - return '/home/user/dev' |
16 | | - }; |
17 | | - |
| 8 | + const basePath = process.cwd(); |
18 | 9 | it('should return true if there is file in list of changed files', function(done) { |
19 | 10 | var fileMocked = {}; |
20 | | - fileMocked.path = 'https://github.com/home/user/dev/src/file33.js'; |
| 11 | + fileMocked.path = path.join(basePath, 'src/file33.js'); |
21 | 12 | var filesChanged = [ |
22 | 13 | 'src/file11.js', |
23 | 14 | 'src/file22.js', |
24 | 15 | 'src/file33.js' |
25 | | - ]; |
| 16 | + ].map(filePath => path.join(basePath, filePath)); |
26 | 17 | var result = gulpGitFlowDiff.isFileChanged(fileMocked, filesChanged); |
27 | 18 | assert.equal(result, true); |
28 | 19 | done(); |
29 | 20 | }); |
30 | 21 |
|
31 | 22 | it('should return false if there is no file in list of changed files', function(done) { |
32 | 23 | var fileMocked = {}; |
33 | | - fileMocked.path = 'https://github.com/usr/home/user/dev/src/file44.js'; |
| 24 | + fileMocked.path = path.join(basePath, 'src/file44.js'); |
34 | 25 | var filesChanged = [ |
35 | 26 | 'src/file11.js', |
36 | 27 | 'src/file22.js', |
37 | 28 | 'src/file33.js' |
38 | | - ]; |
| 29 | + ].map(filePath => path.join(basePath, filePath)); |
39 | 30 | var result = gulpGitFlowDiff.isFileChanged(fileMocked, filesChanged); |
40 | 31 | assert.equal(result, false); |
41 | 32 | done(); |
|
0 commit comments