-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.js
57 lines (53 loc) · 2.16 KB
/
tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var assert = require('assert')
var dircompare = require('dir-compare')
var folderSemver = require('./index')
// dir-compare mock responses
const mockDiffSetEmptyResponse = {} // null
const mockDiffSetAddedResponse = {right:[]} // minor
const mockDiffSetRemovedResponse = {left:[]} // major
const mockDiffSetChangdResponse = {distinct:[]} // patch
const mockDiffSetChangedAddedResponse = {distinct:[], right:[]} // minor
const mockDiffSetChangedRemovedResponse = {distinct:[], left:[]} // major
const mockDiffSetChangedRemovedAddedResponse = {left:[], right:[]} // major
const oldPath = 'oldPath'
const changedPath = 'changedPath'
function mockDircompare(set){
dircompare.compareSync = () => set
}
describe('folderSemver', function() {
it('Should return null with empty folders', function() {
//setup mock here
mockDircompare(mockDiffSetEmptyResponse);
assert.equal(null, folderSemver(oldPath, changedPath));
});
it('Should return major with removed', function() {
//setup mock here
mockDircompare(mockDiffSetRemovedResponse);
assert.equal('major', folderSemver(oldPath, changedPath));
});
it('Should return minor with added', function() {
//setup mock here
mockDircompare(mockDiffSetAddedResponse);
assert.equal('minor', folderSemver(oldPath, changedPath));
});
it('Should return patch with changed', function() {
//setup mock here
mockDircompare(mockDiffSetChangdResponse);
assert.equal('patch', folderSemver(oldPath, changedPath));
});
it('Should return minor with changed added', function() {
//setup mock here
mockDircompare(mockDiffSetChangedAddedResponse);
assert.equal('minor', folderSemver(oldPath, changedPath));
});
it('Should return major with changed and removed', function() {
//setup mock here
mockDircompare(mockDiffSetChangedRemovedResponse);
assert.equal('major', folderSemver(oldPath, changedPath));
});
it('Should return major with changed and removed and added', function() {
//setup mock here
mockDircompare(mockDiffSetChangedRemovedAddedResponse);
assert.equal('major', folderSemver(oldPath, changedPath));
});
})