@rea-jet/rea-xml2js
Advanced tools
Comparing version 2.1.7 to 2.2.0
{ | ||
"name": "@rea-jet/rea-xml2js", | ||
"version": "2.1.7", | ||
"version": "2.2.0", | ||
"description": "REA bidirectional XML to JSON converter", | ||
"main": "index.js", | ||
"main": "dist/index.js", | ||
"bin": { | ||
"toJSON": "./dist/cli.js", | ||
"toXML": "./dist/cli.js" | ||
}, | ||
"scripts": { | ||
"test": "jasmine", | ||
"test:ci": "npm run test" | ||
"prepublish": "BABEL_ENV=production npm run build", | ||
"lint": "eslint src/", | ||
"test": "jest", | ||
"test:ci": "npm run test", | ||
"build": "babel src --out-dir dist", | ||
"watch": "npm run build -- -w --source-maps", | ||
"watch:test": "npm run test -- --watch" | ||
}, | ||
@@ -13,11 +22,12 @@ "author": "Dennis Sänger <dsaenger@rea.de>", | ||
"dependencies": { | ||
"@rea-jet/xml2js": "0.4.13", | ||
"bluebird": "3.5.0", | ||
"lodash": "4", | ||
"q": "1.2.0", | ||
"@rea-jet/xml2js": "0.4" | ||
"q": "1.2.0" | ||
}, | ||
"devDependencies": { | ||
"gulp": "3.8.11", | ||
"gulp-jasmine": "2.0.0", | ||
"jasmine": "2.2.1" | ||
"babel-cli": "6.24.1", | ||
"eslint-config-rea": "2.0.1", | ||
"jest": "20.0.4" | ||
} | ||
} | ||
} |
@@ -1,41 +0,12 @@ | ||
'use strict'; | ||
require('./toMatchXML').extendJest(); | ||
var $q = require('q'); | ||
var UUT = require('../index'); | ||
const Promise = require('bluebird'); | ||
const UUT = require('../src/index'); | ||
var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n'; | ||
const XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n'; | ||
var xmlMatcher = { | ||
toEqualXML: function(util, customEqualityTesters) { | ||
function xmlTrim(str) { | ||
return str | ||
.replace(/<\?xml[^>]*>/, '') | ||
.split(/\n|[\s]{2,}/).join(''); | ||
} | ||
return { | ||
compare: function(actual, expected) { | ||
var result = {}; | ||
actual = xmlTrim(actual); | ||
expected = xmlTrim(expected); | ||
result.pass = util.equals(actual, expected, customEqualityTesters); | ||
result.message = (result.pass) ? | ||
'' : | ||
'Expected ' + actual + ' to XMLEqual ' + expected + ', but it did not'; | ||
return result; | ||
} | ||
}; | ||
} | ||
}; | ||
describe('rea-xml2js', function() { | ||
let uut, opts; | ||
var uut; | ||
var opts; | ||
beforeEach(function() { | ||
beforeEach(() => { | ||
opts = { | ||
@@ -45,17 +16,14 @@ preserveChildrenOrder: true, | ||
}; | ||
jasmine.addMatchers(xmlMatcher); | ||
uut = new UUT(); | ||
}); | ||
describe('toJSON', function() { | ||
it('should return a promise', function() { | ||
var promise = uut.toJSON('<some></some>'); | ||
expect($q.isPromiseAlike(promise)).toBe(true); | ||
describe('toJSON', () => { | ||
it('should return a promise', () => { | ||
const promise = uut.toJSON('<some></some>'); | ||
expect(promise).toBeInstanceOf(Promise); | ||
}); | ||
it('should convert xml to json', function(done) { | ||
var xml = XML_HEADER + '<parent><child blubb="blah">child contents</child></parent>'; | ||
var json = { | ||
it('should convert xml to json', () => { | ||
const xml = XML_HEADER + '<parent><child blubb="blah">child contents</child></parent>'; | ||
const json = { | ||
parent: { | ||
@@ -71,13 +39,10 @@ child: { | ||
uut.toJSON(xml, opts).then(function(result) { | ||
return uut.toJSON(xml, opts).then(result => { | ||
expect(JSON.stringify(result)).toEqual(JSON.stringify(json)); | ||
done(); | ||
}); | ||
}); | ||
it('should convert `REA string-booleans` to booleans', function(done) { | ||
var xml = '<parent><bool>True</bool></parent>'; | ||
var json = { | ||
it('should convert `REA string-booleans` to booleans', () => { | ||
const xml = '<parent><bool>True</bool></parent>'; | ||
const json = { | ||
parent: { | ||
@@ -92,7 +57,5 @@ bool: { | ||
uut.toJSON(xml, opts).then(function(result) { | ||
return uut.toJSON(xml, opts).then(result => { | ||
expect(JSON.stringify(result)).toEqual(JSON.stringify(json)); | ||
done(); | ||
}); | ||
}); | ||
@@ -104,10 +67,11 @@ | ||
var xml = '<parent><a>1</a><b>2</b><a>3</a></parent>'; | ||
uut.toJSON(xml, JSON.parse(optsString)) | ||
.then(function(json) { | ||
return uut.toXML(json, JSON.parse(optsString)); | ||
}) | ||
.then(function(result) { | ||
expect(xml).toEqualXML(result); | ||
done(); | ||
}); | ||
uut | ||
.toJSON(xml, JSON.parse(optsString)) | ||
.then(function(json) { | ||
return uut.toXML(json, JSON.parse(optsString)); | ||
}) | ||
.then(function(result) { | ||
expect(xml).toMatchXML(result); | ||
done(); | ||
}); | ||
}); | ||
@@ -117,4 +81,3 @@ | ||
var xml = '<parent><a>1</a><b>2</b><a>3</a><b>3</b></parent>'; | ||
uut.toJSON(xml, opts) | ||
.then(function(json) { | ||
uut.toJSON(xml, opts).then(function(json) { | ||
expect(json.parent.a[0]['#index']).toEqual(0); | ||
@@ -128,13 +91,17 @@ expect(json.parent.a[1]['#index']).toEqual(2); | ||
it('should work with empty tags', () => { | ||
const xml = '<parent><a>1</a><a/></parent>'; | ||
return uut.toJSON(xml, opts).then(json => uut.toXML(json)).then(xmlOut => { | ||
expect(xmlOut).toMatchXML(xml); | ||
}); | ||
}); | ||
}); | ||
describe('toXML', function() { | ||
it('should return a promise', function() { | ||
var promise = uut.toXML({}); | ||
expect($q.isPromiseAlike(promise)).toBe(true); | ||
expect(promise).toBeInstanceOf(Promise); | ||
}); | ||
it('should convert json to xml', function(done) { | ||
var json = { | ||
@@ -153,7 +120,5 @@ parent: { | ||
}); | ||
}); | ||
it('should convert booleans to `REA string-booleans`', function(done) { | ||
var json = { | ||
@@ -175,7 +140,5 @@ parent: { | ||
}); | ||
}); | ||
it('should convert booleans according to translationMap', function(done) { | ||
var json = { | ||
@@ -198,7 +161,4 @@ parent: { | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -205,0 +165,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9687
4
10
193
3
3
1
+ Addedbluebird@3.5.0
+ Addedbluebird@3.5.0(transitive)
Updated@rea-jet/xml2js@0.4.13