1
0
mirror of https://github.com/musix-org/musix-oss synced 2025-06-17 04:26:00 +00:00
This commit is contained in:
MatteZ02
2020-03-03 22:30:50 +02:00
parent edfcc6f474
commit 30022c7634
11800 changed files with 1984416 additions and 1 deletions

31
node_modules/json-bigint/test/bigint-test.js generated vendored Normal file
View File

@ -0,0 +1,31 @@
var mocha = require('mocha')
, assert = require('chai').assert
, expect = require('chai').expect
, BigNumber = require('bignumber.js')
;
describe("Testing bigint support", function(){
var input = '{"big":9223372036854775807,"small":123}';
it("Should show classic JSON.parse lacks bigint support", function(done){
var obj = JSON.parse(input);
expect(obj.small.toString(), "string from small int").to.equal("123");
expect(obj.big.toString(), "string from big int").to.not.equal("9223372036854775807");
var output = JSON.stringify(obj);
expect(output).to.not.equal(input);
done();
});
it("Should show JSNbig does support bigint parse/stringify roundtrip", function(done){
var JSONbig = require('../index');
var obj = JSONbig.parse(input);
expect(obj.small.toString(), "string from small int").to.equal("123");
expect(obj.big.toString(), "string from big int").to.equal("9223372036854775807");
expect(obj.big, "instanceof big int").to.be.instanceof(BigNumber);
var output = JSONbig.stringify(obj);
expect(output).to.equal(input);
done();
});
});

34
node_modules/json-bigint/test/strict-option-test.js generated vendored Normal file
View File

@ -0,0 +1,34 @@
var mocha = require('mocha')
, assert = require('chai').assert
, expect = require('chai').expect
;
describe("Testing 'strict' option", function(){
var dupkeys = '{ "dupkey": "value 1", "dupkey": "value 2"}';
it("Should show that duplicate keys just get overwritten by default", function(done){
var JSONbig = require('../index');
var result = "before";
function tryParse() {
result = JSONbig.parse(dupkeys);
}
expect(tryParse).to.not.throw("anything");
expect(result.dupkey).to.equal("value 2");
done();
});
it("Should show that the 'strict' option will fail-fast on duplicate keys", function(done){
var JSONstrict = require('../index')({"strict": true});
var result = "before";
function tryParse() {
result = JSONstrict.parse(dupkeys);
}
expect(tryParse).to.throw({
name: 'SyntaxError',
message: 'Duplicate key "dupkey"',
at: 33,
text: '{ "dupkey": "value 1", "dupkey": "value 2"}'
});
expect(result).to.equal("before");
done();
});
});

21
node_modules/json-bigint/test/string-option-test.js generated vendored Normal file
View File

@ -0,0 +1,21 @@
var mocha = require('mocha')
, assert = require('chai').assert
, expect = require('chai').expect
;
describe("Testing 'storeAsString' option", function(){
var key = '{ "key": 12345678901234567 }';
it("Should show that the key is of type object", function(done){
var JSONbig = require('../index');
var result = JSONbig.parse(key);
expect(typeof result.key).to.equal("object");
done();
});
it("Should show that key is of type string, when storeAsString option is true", function(done){
var JSONstring = require('../index')({"storeAsString": true});
var result = JSONstring.parse(key);
expect(typeof result.key).to.equal("string");
done();
});
});