fix decode function
This commit is contained in:
parent
1a61f86bea
commit
50a1b7e2d5
2 changed files with 41 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
import { describe, beforeEach, it, expect, mock, afterAll, spyOn } from 'bun:test';
|
||||
import { debounce, deepCopy, deepDiff, filter, map, MutarionKind, splitAt } from './utilities';
|
||||
import { describe, beforeEach, it, expect, afterAll, spyOn } from 'bun:test';
|
||||
import { decode, deepCopy, deepDiff, filter, map, MutarionKind, splitAt } from './utilities';
|
||||
import { install } from '@sinonjs/fake-timers';
|
||||
|
||||
type MilliSeconds = number;
|
||||
|
@ -72,6 +72,44 @@ describe('utilities', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('decode', () => {
|
||||
it('should decode \\t characters', async () => {
|
||||
// Arrange
|
||||
const given = 'this is\\ta string';
|
||||
const expected = 'this is\ta string';
|
||||
|
||||
// Act
|
||||
const actual = decode(given);
|
||||
|
||||
// Assert
|
||||
expect(actual).toBe(expected);
|
||||
});
|
||||
|
||||
it('should decode \\n characters', async () => {
|
||||
// Arrange
|
||||
const given = 'this is\\na string';
|
||||
const expected = 'this is\na string';
|
||||
|
||||
// Act
|
||||
const actual = decode(given);
|
||||
|
||||
// Assert
|
||||
expect(actual).toBe(expected);
|
||||
});
|
||||
|
||||
it('should decode \\uHHHH characters', async () => {
|
||||
// Arrange
|
||||
const given = 'this is \\u1234 a string';
|
||||
const expected = 'this is \u1234 a string';
|
||||
|
||||
// Act
|
||||
const actual = decode(given);
|
||||
|
||||
// Assert
|
||||
expect(actual).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('deepCopy', () => {
|
||||
it('can skip values passed by reference (non-objects, null, and undefined)', async () => {
|
||||
// arrange
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue