mirror of
https://github.com/directus/directus.git
synced 2026-01-29 05:48:14 -05:00
25 lines
707 B
TypeScript
25 lines
707 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { noproto, parseJSON } from './parse-json';
|
|
|
|
describe('noproto', () => {
|
|
it('Returns the value if the key is not __proto__', () => {
|
|
let result = noproto('anything', 'value');
|
|
expect(result).toBe('value');
|
|
|
|
result = noproto('__proto__', 'malicious');
|
|
expect(result).toBe(undefined);
|
|
});
|
|
});
|
|
|
|
describe('parseJSON', () => {
|
|
it('Parses JSON strings', () => {
|
|
const result = parseJSON(`{"name": "Directus"}`);
|
|
expect(result).toEqual({ name: 'Directus' });
|
|
});
|
|
|
|
it('Ignores __proto__ properties', () => {
|
|
const result = parseJSON(`{"name": "Directus", "__proto__": "malicious" }`);
|
|
expect(result).toEqual({ name: 'Directus' });
|
|
});
|
|
});
|