This commit is contained in:
oitsjustjose 2017-02-26 17:06:42 -05:00
commit 6b60015c02
9588 changed files with 1149251 additions and 49 deletions

172
node_modules/gulp-json-editor/test/byFunction.js generated vendored Normal file
View file

@ -0,0 +1,172 @@
/* jshint node: true */
/* global it */
var json = require('../');
var gulp = require("gulp");
require('should');
require('mocha');
it('should modify property of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
obj.version = '2.0.0';
return obj;
}));
stream.on('data', function(file) {
var expected =
'{\n' +
' "name": "test object",\n' +
' "version": "2.0.0",\n' +
' "nested": {\n' +
' "name": "nested object",\n' +
' "version": "1.0.0"\n' +
' }\n' +
'}'
file.contents.toString().should.eql(expected);
done();
});
});
it('should add property of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
obj.description = 'this is test';
return obj;
}));
stream.on('data', function(file) {
var expected =
'{\n' +
' "name": "test object",\n' +
' "version": "1.0.0",\n' +
' "nested": {\n' +
' "name": "nested object",\n' +
' "version": "1.0.0"\n' +
' },\n' +
' "description": "this is test"\n' +
'}'
file.contents.toString().should.eql(expected);
done();
});
});
it('should remove property of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
delete obj.name;
return obj;
}));
stream.on('data', function(file) {
var expected =
'{\n' +
' "version": "1.0.0",\n' +
' "nested": {\n' +
' "name": "nested object",\n' +
' "version": "1.0.0"\n' +
' }\n' +
'}'
file.contents.toString().should.eql(expected);
done();
});
});
it('should modify nested property of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
obj.nested.version = '2.0.1';
return obj;
}));
stream.on('data', function(file) {
var expected =
'{\n' +
' "name": "test object",\n' +
' "version": "1.0.0",\n' +
' "nested": {\n' +
' "name": "nested object",\n' +
' "version": "2.0.1"\n' +
' }\n' +
'}'
file.contents.toString().should.eql(expected);
done();
});
});
it('should add nested property of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
obj.nested.description = 'this is test for nested';
return obj;
}));
stream.on('data', function(file) {
var expected =
'{\n' +
' "name": "test object",\n' +
' "version": "1.0.0",\n' +
' "nested": {\n' +
' "name": "nested object",\n' +
' "version": "1.0.0",\n' +
' "description": "this is test for nested"\n' +
' }\n' +
'}'
file.contents.toString().should.eql(expected);
done();
});
});
it('should remove nested property of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
delete obj.nested.name;
return obj;
}));
stream.on('data', function(file) {
var expected =
'{\n' +
' "name": "test object",\n' +
' "version": "1.0.0",\n' +
' "nested": {\n' +
' "version": "1.0.0"\n' +
' }\n' +
'}'
file.contents.toString().should.eql(expected);
done();
});
});
it('should multiple properties of JSON object (by function editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json(function(obj) {
obj.version = '2.0.0';
obj.description = 'this is test';
delete obj.name;
obj.nested.version = '2.0.1';
obj.nested.description = 'this is test for nested';
delete obj.nested.name;
return obj;
}));
stream.on('data', function(file) {
var expected =
'{\n' +
' "version": "2.0.0",\n' +
' "nested": {\n' +
' "version": "2.0.1",\n' +
' "description": "this is test for nested"\n' +
' },\n' +
' "description": "this is test"\n' +
'}'
file.contents.toString().should.eql(expected);
done();
});
});

129
node_modules/gulp-json-editor/test/byObject.js generated vendored Normal file
View file

@ -0,0 +1,129 @@
/* jshint node: true */
/* global it */
var json = require('../');
var gulp = require("gulp");
require('should');
require('mocha');
it('should modify property of JSON object (by object editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json({
version: '2.0.0'
}));
stream.on('data', function(file) {
var expected =
'{\n' +
' "name": "test object",\n' +
' "version": "2.0.0",\n' +
' "nested": {\n' +
' "name": "nested object",\n' +
' "version": "1.0.0"\n' +
' }\n' +
'}'
file.contents.toString().should.eql(expected);
done();
});
});
it('should add property of JSON object (by object editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json({
description: 'this is test'
}));
stream.on('data', function(file) {
var expected =
'{\n' +
' "name": "test object",\n' +
' "version": "1.0.0",\n' +
' "nested": {\n' +
' "name": "nested object",\n' +
' "version": "1.0.0"\n' +
' },\n' +
' "description": "this is test"\n' +
'}'
file.contents.toString().should.eql(expected);
done();
});
});
it('should modify nested property of JSON object (by object editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json({
nested: {
version: '2.0.1'
}
}));
stream.on('data', function(file) {
var expected =
'{\n' +
' "name": "test object",\n' +
' "version": "1.0.0",\n' +
' "nested": {\n' +
' "name": "nested object",\n' +
' "version": "2.0.1"\n' +
' }\n' +
'}'
file.contents.toString().should.eql(expected);
done();
});
});
it('should add nested property of JSON object (by object editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json({
nested: {
description: 'this is test for nested'
}
}));
stream.on('data', function(file) {
var expected =
'{\n' +
' "name": "test object",\n' +
' "version": "1.0.0",\n' +
' "nested": {\n' +
' "name": "nested object",\n' +
' "version": "1.0.0",\n' +
' "description": "this is test for nested"\n' +
' }\n' +
'}'
file.contents.toString().should.eql(expected);
done();
});
});
it('should multiple properties of JSON object (by object editor)', function(done) {
var stream = gulp.src('test/test.json').pipe(json({
version: '2.0.0',
description: 'this is test',
nested: {
version: '2.0.1',
description: 'this is test for nested'
}
}));
stream.on('data', function(file) {
var expected =
'{\n' +
' "name": "test object",\n' +
' "version": "2.0.0",\n' +
' "nested": {\n' +
' "name": "nested object",\n' +
' "version": "2.0.1",\n' +
' "description": "this is test for nested"\n' +
' },\n' +
' "description": "this is test"\n' +
'}'
file.contents.toString().should.eql(expected);
done();
});
});

41
node_modules/gulp-json-editor/test/error.js generated vendored Normal file
View file

@ -0,0 +1,41 @@
/* jshint node: true */
/* global it */
var jedit = require('../');
var gutil = require('gulp-util');
var fs = require('fs');
var should = require('should');
require('mocha');
it('should raise error when missing option', function(done) {
should(function(){jedit();}).throw('missing "editor" option');
done();
});
it('should raise error when invalid type of option', function(done) {
should(function(){jedit(1);}).throw('"editor" option must be a function or object');
done();
});
it('should do path-through when input is null', function(done) {
jedit({})
.on('data', function(file) {
should(file.contents).eql(null);
done();
})
.write(new gutil.File({}));
});
it('should raise error when streaming input', function(done) {
jedit({})
.on('error', function(err) {
err.message.should.equal('Streaming is not supported');
done();
})
.write(new gutil.File({
contents: fs.createReadStream('test/test.json')
}));
});

92
node_modules/gulp-json-editor/test/option.js generated vendored Normal file
View file

@ -0,0 +1,92 @@
/* jshint node: true */
/* global it */
var json = require('../');
var gulp = require("gulp");
require('should');
require('mocha');
it('should pass-through second argument to js-beautify', function(done) {
var stream = gulp.src('test/test.json').pipe(json({
version: '2.0.0',
description: 'this is test',
array: [
'1234567890', '1234567890', '1234567890', '1234567890', '1234567890', '1234567890', '1234567890', '1234567890'
],
nested: {
version: '2.0.1',
description: 'this is test for nested'
}
},
{
'indent_size': 3,
'indent_char': '\t',
'brace_style': 'expand',
'preserve_newlines' : false,
'wrap_line_length': 80
}));
stream.on('data', function(file) {
var expected =
'{\n' +
'\t\t\t"name": "test object",\n' +
'\t\t\t"version": "2.0.0",\n' +
'\t\t\t"nested":\n' +
'\t\t\t{\n' +
'\t\t\t\t\t\t"name": "nested object",\n' +
'\t\t\t\t\t\t"version": "2.0.1",\n' +
'\t\t\t\t\t\t"description": "this is test for nested"\n' +
'\t\t\t},\n' +
'\t\t\t"description": "this is test",\n' +
'\t\t\t"array": ["1234567890", "1234567890", "1234567890", "1234567890",\n' +
'\t\t\t\t\t\t"1234567890", "1234567890", "1234567890", "1234567890"\n' +
'\t\t\t]\n' +
'}';
file.contents.toString().should.eql(expected);
done();
});
});
it('should keep indentation', function(done) {
var stream = gulp.src('test/test.json').pipe(json({
version: '2.0.0',
description: 'this is test',
array: [
'1234567890', '1234567890', '1234567890', '1234567890', '1234567890', '1234567890', '1234567890', '1234567890'
],
nested: {
version: '2.0.1',
description: 'this is test for nested'
}
},
{
'brace_style': 'expand',
'preserve_newlines' : false,
'wrap_line_length': 80
}));
stream.on('data', function(file) {
var expected =
'{\n' +
' "name": "test object",\n' +
' "version": "2.0.0",\n' +
' "nested":\n' +
' {\n' +
' "name": "nested object",\n' +
' "version": "2.0.1",\n' +
' "description": "this is test for nested"\n' +
' },\n' +
' "description": "this is test",\n' +
' "array": ["1234567890", "1234567890", "1234567890", "1234567890",\n' +
' "1234567890", "1234567890", "1234567890", "1234567890"\n' +
' ]\n' +
'}';
file.contents.toString().should.eql(expected);
done();
});
});

8
node_modules/gulp-json-editor/test/test.json generated vendored Normal file
View file

@ -0,0 +1,8 @@
{
"name": "test object",
"version": "1.0.0",
"nested": {
"name": "nested object",
"version": "1.0.0"
}
}