File size: 793 Bytes
f0634fb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | import { describe, expect, it } from 'vitest';
import {
migrateWireRecord,
type WireMigration,
} from '#/wire/migration/migration';
describe('wire record migrations', () => {
it('applies migrations in order', () => {
const migrations: WireMigration[] = [
{
sourceVersion: '0.8',
targetVersion: '0.9',
migrateRecord: (record) => ({
...record,
first: true,
}),
},
{
sourceVersion: '0.9',
targetVersion: '1.0',
migrateRecord: (record) => ({
...record,
second: record['first'] === true,
}),
},
];
expect(migrateWireRecord({ type: 'metadata' }, migrations)).toEqual({
type: 'metadata',
first: true,
second: true,
});
});
});
|