Add white migration (#3334)

This PR adds a down migration for #3321.

### Change Type

- [x] `sdk` — Changes the tldraw SDK
- [x] `dunno` — I don't know
mitja/rotation
Steve Ruiz 2024-04-04 19:16:17 +01:00 zatwierdzone przez GitHub
rodzic 0161ec796e
commit 43edeb09b5
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
3 zmienionych plików z 48 dodań i 3 usunięć

Wyświetl plik

@ -2387,7 +2387,7 @@
},
{
"kind": "Content",
"text": "Value | (() => Value)"
"text": "(() => Value) | Value"
},
{
"kind": "Content",
@ -2813,7 +2813,7 @@
},
{
"kind": "Content",
"text": "undefined | any[]"
"text": "any[] | undefined"
},
{
"kind": "Content",

Wyświetl plik

@ -2030,6 +2030,34 @@ describe('Fractional indexing for line points', () => {
})
})
describe('add white', () => {
const { up, down } = rootShapeMigrations.migrators[rootShapeVersions.AddWhite]
test('up works as expected', () => {
expect(
up({
props: {},
})
).toEqual({
props: {},
})
})
test('down works as expected', () => {
expect(
down({
props: {
color: 'white',
},
})
).toEqual({
props: {
color: 'black',
},
})
})
})
/* --- PUT YOUR MIGRATIONS TESTS ABOVE HERE --- */
for (const migrator of allMigrators) {

Wyświetl plik

@ -87,11 +87,12 @@ export const rootShapeVersions = {
AddIsLocked: 1,
HoistOpacity: 2,
AddMeta: 3,
AddWhite: 4,
} as const
/** @internal */
export const rootShapeMigrations = defineMigrations({
currentVersion: rootShapeVersions.AddMeta,
currentVersion: rootShapeVersions.AddWhite,
migrators: {
[rootShapeVersions.AddIsLocked]: {
up: (record) => {
@ -147,6 +148,22 @@ export const rootShapeMigrations = defineMigrations({
}
},
},
[rootShapeVersions.AddWhite]: {
up: (record) => {
return {
...record,
}
},
down: (record) => {
return {
...record,
props: {
...record.props,
color: record.props.color === 'white' ? 'black' : record.props.color,
},
}
},
},
},
})