Backend half
This commit is contained in:
+11
-19
@@ -8,8 +8,7 @@ var SaferBuffer = require('safer-buffer').Buffer;
|
||||
var hasSymbols = require('has-symbols');
|
||||
var mockProperty = require('mock-property');
|
||||
var emptyTestCases = require('./empty-keys-cases').emptyTestCases;
|
||||
var hasProto = require('has-proto')();
|
||||
var hasBigInt = require('has-bigints')();
|
||||
var hasBigInt = typeof BigInt === 'function';
|
||||
|
||||
test('stringify()', function (t) {
|
||||
t.test('stringifies a querystring object', function (st) {
|
||||
@@ -651,8 +650,10 @@ test('stringify()', function (t) {
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies a null object', { skip: !hasProto }, function (st) {
|
||||
st.equal(qs.stringify({ __proto__: null, a: 'b' }), 'a=b');
|
||||
t.test('stringifies a null object', { skip: !Object.create }, function (st) {
|
||||
var obj = Object.create(null);
|
||||
obj.a = 'b';
|
||||
st.equal(qs.stringify(obj), 'a=b');
|
||||
st.end();
|
||||
});
|
||||
|
||||
@@ -664,8 +665,11 @@ test('stringify()', function (t) {
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies an object with a null object as a child', { skip: !hasProto }, function (st) {
|
||||
st.equal(qs.stringify({ a: { __proto__: null, b: 'c' } }), 'a%5Bb%5D=c');
|
||||
t.test('stringifies an object with a null object as a child', { skip: !Object.create }, function (st) {
|
||||
var obj = { a: Object.create(null) };
|
||||
|
||||
obj.a.b = 'c';
|
||||
st.equal(qs.stringify(obj), 'a%5Bb%5D=c');
|
||||
st.end();
|
||||
});
|
||||
|
||||
@@ -1250,7 +1254,7 @@ test('stringify()', function (t) {
|
||||
};
|
||||
|
||||
st.equal(
|
||||
qs.stringify(obj, { arrayFormat: 'brackets', charset: 'utf-8' }),
|
||||
qs.stringify(obj, { arrayFormat: 'bracket', charset: 'utf-8' }),
|
||||
'foo=' + expected.join('')
|
||||
);
|
||||
|
||||
@@ -1291,16 +1295,4 @@ test('stringifies empty keys', function (t) {
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.test('stringifies non-string keys', function (st) {
|
||||
var actual = qs.stringify({ a: 'b', 'false': {} }, {
|
||||
filter: ['a', false, null],
|
||||
allowDots: true,
|
||||
encodeDotInKeys: true
|
||||
});
|
||||
|
||||
st.equal(actual, 'a=b', 'stringifies correctly');
|
||||
|
||||
st.end();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user