mirror of
https://github.com/TheodoreKrypton/tgfs
synced 2024-11-22 15:25:22 +00:00
40 lines
947 B
TypeScript
40 lines
947 B
TypeScript
import { TGFSDirectory } from 'src/model/directory';
|
|
|
|
describe('serialization and deserialization', () => {
|
|
it('should equal to the original directory', () => {
|
|
const d1 = new TGFSDirectory('d1', null);
|
|
const d2 = d1.createChild('d2');
|
|
d2.createFileRef('f1', { id: 1 } as any);
|
|
|
|
expect(TGFSDirectory.fromObject(d1.toObject()).toObject()).toEqual(
|
|
d1.toObject(),
|
|
);
|
|
});
|
|
|
|
it('should equal to the expected structure', () => {
|
|
const d1 = new TGFSDirectory('d1', null);
|
|
const d2 = d1.createChild('d2');
|
|
d2.createFileRef('f1', { id: 1 } as any);
|
|
|
|
expect(d1.toObject()).toEqual({
|
|
name: 'd1',
|
|
type: 'D',
|
|
children: [
|
|
{
|
|
name: 'd2',
|
|
type: 'D',
|
|
children: [],
|
|
files: [
|
|
{
|
|
name: 'f1',
|
|
type: 'FR',
|
|
messageId: 1,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
files: [],
|
|
});
|
|
});
|
|
});
|