forked from jspm/jspm-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpjson.js
34 lines (30 loc) · 1017 Bytes
/
pjson.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
var PackageJSON = require('../lib/config/package');
var fs = require('fs');
var mkdirp = require('mkdirp');
var path = require('path');
suite('package.json', function() {
var inputs = fs.readdirSync('./test/fixtures/pjson/initial');
mkdirp.sync('./test/outputs/pjson');
inputs.forEach(function(input) {
test(input.replace(/\.json$/, ''), function(done) {
var test = new PackageJSON(path.resolve('./test/fixtures/pjson/initial/' + input));
return Promise.resolve(test.read())
.then(function() {
test.fileName = './test/outputs/pjson/' + input;
return test.write();
})
.then(function() {
var expected = fs.readFileSync('./test/fixtures/pjson/expected/' + input).toString();
var actual = fs.readFileSync('./test/outputs/pjson/' + input).toString();
try {
assert.equal(actual, expected);
}
catch(e) {
e.showDiff = true;
throw e;
}
})
.then(done, done);
});
});
});