apphouse
Version:
Component library for React that uses observable state management and theme-able components.
42 lines (39 loc) • 914 B
text/typescript
import { toArray } from './toArray';
describe('toArray', () => {
test('should transform an object into an array of key-value pairs', () => {
const obj = { name: 'John', age: 30, city: 'New York' };
const arr = toArray(obj);
expect(arr).toEqual([
['name', 'John'],
['age', 30],
['city', 'New York']
]);
});
test('should handle an empty object', () => {
const obj = {};
const arr = toArray(obj);
expect(arr).toEqual([]);
});
test('should handle an object with nested objects', () => {
const obj = {
name: 'John',
age: 30,
address: {
street: '123 Main St',
city: 'New York'
}
};
const arr = toArray(obj);
expect(arr).toEqual([
['name', 'John'],
['age', 30],
[
'address',
{
street: '123 Main St',
city: 'New York'
}
]
]);
});
});