forked from apache/cordova-node-xcode
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathguidMapper.js
More file actions
69 lines (62 loc) · 2.05 KB
/
guidMapper.js
File metadata and controls
69 lines (62 loc) · 2.05 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
var guidMapper = require('../lib/guidMapper');
const fs = require('fs');
const $uuid = require('uuid');
const TEST_FILE_NAME = 'test/.ns-build-pbxgroup-data.json';
const goodGUID = $uuid.v4();
const goodName = "goodName";
const badName = 'badName';
const goodPath = "goodPath";
const badPath = "badPath";
exports.setUp = function(callback) {
if(fs.existsSync(TEST_FILE_NAME)){
fs.rmSync(TEST_FILE_NAME);
}
callback();
}
exports.tearDown = function(callback) {
if(fs.existsSync(TEST_FILE_NAME)){
fs.rmSync(TEST_FILE_NAME);
}
callback();
}
function addTestData(){
var mapper = new guidMapper(TEST_FILE_NAME);
mapper.addEntry(goodGUID, goodPath, goodName);
mapper.writeFileSync();
}
exports.operations = {
'should be able to add to map': function(test) {
var mapper = new guidMapper(TEST_FILE_NAME);
mapper.addEntry(goodGUID, goodPath, goodName);
mapper.writeFileSync();
mapper = new guidMapper(TEST_FILE_NAME);
const result = mapper.findEntryGuid(goodName, goodPath);
test.ok(result === goodGUID)
test.done();
},
'should not match only on name': function(test) {
addTestData();
var mapper = new guidMapper(TEST_FILE_NAME);
const result = mapper.findEntryGuid(goodName, badPath);
test.ok(result === null)
test.done();
},
'should not match only on path': function(test) {
addTestData();
var mapper = new guidMapper(TEST_FILE_NAME);
const result = mapper.findEntryGuid(badName, goodPath);
test.ok(result === null)
test.done();
},
'can remove': function(test) {
addTestData();
var mapper = new guidMapper(TEST_FILE_NAME);
mapper.removeEntry(goodGUID);
var result = mapper.findEntryGuid(goodName, goodPath);
test.ok(result === null);
mapper.writeFileSync();
result = mapper.findEntryGuid(goodName, goodPath);
test.ok(result === null)
test.done();
}
}