|
12345678910111213141516171819202122232425262728293031323334 |
- import { describe, expect, it } from 'vitest';
- import { deserialize, serialize } from '../../src/types/application/x-www-form-urlencoded';
-
- describe('application/x-www-form-urlencoded', () => {
- describe('serialize', () => {
- it('should throw when serializing a string', () => {
- expect(() => serialize('Hello, World!')).toThrow();
- });
-
- it('should throw when serializing a number', () => {
- expect(() => serialize(123)).toThrow();
- });
-
- it('should throw when serializing a boolean', () => {
- expect(() => serialize(true)).toThrow();
- });
-
- it('should throw when serializing an array', () => {
- expect(() => serialize([1, 2, 3])).toThrow();
- });
-
- it('should serialize an object', () => {
- const result = serialize({ a: 1, b: 2, c: 3 });
- expect(result).toBe('a=1&b=2&c=3');
- });
- });
-
- describe('deserialize', () => {
- it('should deserialize an object', () => {
- const result = deserialize<{ a: string, b: string, c: string }>('a=1&b=2&c=3');
- expect(result).toEqual({ a: '1', b: '2', c: '3' });
- });
- });
- });
|