-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.test.js
More file actions
22 lines (21 loc) · 831 Bytes
/
index.test.js
File metadata and controls
22 lines (21 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const sortKeys = require('sort-keys');
const path = require('path');
const tap = require('tap');
const fs = require('fs');
const parse = require('./')(fs.readFileSync(path.resolve(__dirname, 'test', 'template.xml')).toString());
const payload = fs.readFileSync(path.resolve(__dirname, 'test', 'payload.xml')).toString();
tap.test('parse', async assert => {
assert.matchSnapshot(sortKeys(await parse(payload)), 'parse xml string to object');
assert.matchSnapshot(await parse(payload, true), 'parse xml string to JSON');
assert.matchSnapshot(sortKeys(await parse({
some: {
deep: {
nested: {
structure: 'value 1'
}
},
veryVeryLongTagName: 'value 2'
}
})), 'extract object from parsed xml');
assert.end();
});