-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
122 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* IMPORTANT | ||
* This snapshot file is auto-generated, but designed for humans. | ||
* It should be checked into source control and tracked carefully. | ||
* Re-generate by setting TAP_SNAPSHOT=1 and running tests. | ||
* Make sure to inspect the output below. Do not ignore changes! | ||
*/ | ||
'use strict' | ||
exports[`test/duplicate-properties.js TAP decode duplicate properties with bracketedArray=false > must match snapshot 1`] = ` | ||
Null Object { | ||
"ar": Array [ | ||
"three", | ||
], | ||
"ar[]": "one", | ||
"b": Array [ | ||
"2", | ||
"3", | ||
"3", | ||
], | ||
"brr": "1", | ||
"str": "3", | ||
"zr": "123", | ||
"zr[]": "deedee", | ||
} | ||
` | ||
|
||
exports[`test/duplicate-properties.js TAP decode with duplicate properties > must match snapshot 1`] = ` | ||
Null Object { | ||
"ar": Array [ | ||
"one", | ||
"three", | ||
], | ||
"brr": "3", | ||
"str": "3", | ||
"zr": Array [ | ||
"deedee", | ||
"123", | ||
], | ||
} | ||
` | ||
|
||
exports[`test/duplicate-properties.js TAP encode duplicate properties with bracketedArray=false > must match snapshot 1`] = ` | ||
ar=1 | ||
ar=2 | ||
ar=3 | ||
br=1 | ||
br=2 | ||
` | ||
|
||
exports[`test/duplicate-properties.js TAP encode with duplicate properties > must match snapshot 1`] = ` | ||
ar[]=1 | ||
ar[]=2 | ||
ar[]=3 | ||
br[]=1 | ||
br[]=2 | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const i = require('../') | ||
const tap = require('tap') | ||
const test = tap.test | ||
const fs = require('fs') | ||
const path = require('path') | ||
|
||
const fixture = path.resolve(__dirname, './fixtures/duplicate.ini') | ||
const data = fs.readFileSync(fixture, 'utf8') | ||
|
||
tap.cleanSnapshot = s => s.replace(/\r\n/g, '\n') | ||
|
||
test('decode with duplicate properties', function (t) { | ||
const d = i.decode(data) | ||
t.matchSnapshot(d) | ||
t.end() | ||
}) | ||
|
||
test('encode with duplicate properties', function (t) { | ||
const e = i.encode({ | ||
ar: ['1', '2', '3'], | ||
br: ['1', '2'], | ||
}) | ||
t.matchSnapshot(e) | ||
t.end() | ||
}) | ||
|
||
test('decode duplicate properties with bracketedArray=false', function (t) { | ||
const d = i.decode(data, { bracketedArray: false }) | ||
t.matchSnapshot(d) | ||
t.end() | ||
}) | ||
|
||
test('encode duplicate properties with bracketedArray=false', function (t) { | ||
const e = i.encode({ | ||
ar: ['1', '2', '3'], | ||
br: ['1', '2'], | ||
}, { bracketedArray: false }) | ||
t.matchSnapshot(e) | ||
t.end() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
zr[] = deedee | ||
zr=123 | ||
ar[] = one | ||
ar[] = three | ||
str = 3 | ||
brr = 1 | ||
brr = 2 | ||
brr = 3 | ||
brr = 3 |