Add tests
This commit is contained in:
parent
f62dd56dd6
commit
14fc91d58a
|
@ -190,15 +190,9 @@ export async function doInAppMigrationContext<T>(
|
|||
appId: string,
|
||||
task: () => T
|
||||
): Promise<T> {
|
||||
try {
|
||||
return _doInAppContext(appId, task, {
|
||||
isMigrating: true,
|
||||
})
|
||||
} finally {
|
||||
updateContext({
|
||||
isMigrating: undefined,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export function getIdentity(): IdentityContext | undefined {
|
||||
|
|
|
@ -179,5 +179,23 @@ describe("context", () => {
|
|||
expect(context).toEqual(expected)
|
||||
})
|
||||
})
|
||||
|
||||
it("the context is not modified outside the delegate", async () => {
|
||||
const appId = db.generateAppID()
|
||||
|
||||
expect(Context.get()).toBeUndefined()
|
||||
|
||||
await context.doInAppMigrationContext(appId, () => {
|
||||
const context = Context.get()
|
||||
|
||||
const expected: ContextMap = {
|
||||
appId,
|
||||
isMigrating: true,
|
||||
}
|
||||
expect(context).toEqual(expected)
|
||||
})
|
||||
|
||||
expect(Context.get()).toBeUndefined()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue