mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-18 11:28:23 -07:00
34 lines
942 B
JavaScript
34 lines
942 B
JavaScript
import test from 'ava';
|
|
import fn from '../';
|
|
|
|
test('stringify', t => {
|
|
t.same(fn.stringify({foo: 'bar'}), 'foo=bar');
|
|
t.same(fn.stringify({foo: 'bar', bar: 'baz'}), 'bar=baz&foo=bar');
|
|
});
|
|
|
|
test('different types', t => {
|
|
t.same(fn.stringify(), '');
|
|
t.same(fn.stringify(0), '');
|
|
});
|
|
|
|
test('URI encode', t => {
|
|
t.same(fn.stringify({'foo bar': 'baz faz'}), 'foo%20bar=baz%20faz');
|
|
t.same(fn.stringify({'foo bar': 'baz\'faz'}), 'foo%20bar=baz%27faz');
|
|
});
|
|
|
|
test('handle array value', t => {
|
|
t.same(fn.stringify({abc: 'abc', foo: ['bar', 'baz']}), 'abc=abc&foo=bar&foo=baz');
|
|
});
|
|
|
|
test('handle empty array value', t => {
|
|
t.same(fn.stringify({abc: 'abc', foo: []}), 'abc=abc');
|
|
});
|
|
|
|
test('should not encode undefined values', t => {
|
|
t.same(fn.stringify({abc: undefined, foo: 'baz'}), 'foo=baz');
|
|
});
|
|
|
|
test('should encode null values as just a key', t => {
|
|
t.same(fn.stringify({xyz: null, abc: null, foo: 'baz'}), 'abc&foo=baz&xyz');
|
|
});
|