Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
unit(server): prepare test to finish progress
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Oct 15, 2022
1 parent 39a54ca commit b551536
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions server/singletons/asynchronous_operation_manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,40 @@ describe("Server singleton: Asynchronous operation manager", () => {
expect(deserializedDocument).toHaveProperty("data.totalStepCount", totalStepCount)
expect(deserializedDocument).toHaveProperty("data.extra", { "message": newMessage })
})

it("can finish progress even if other steps will be skipped", async() => {
const singleton = new Singleton()
const userFactory = new UserFactory()
const user = await userFactory.insertOne()
const body = Buffer.alloc(0)
const finishedStepCount = 2
const totalStepCount = 5
const message = "hello"
await new Factory()
.token(() => digest(body))
.user(() => Promise.resolve(user))
.finishedStepCount(() => finishedStepCount)
.totalStepCount(() => totalStepCount)
.extra(() => ({ message }))
.insertOne()
requester.customizeRequest({
body,
"user": await userFactory.serialize(user)
})
await requester.runAsynchronousOperationInitializer(
singleton.initializeWithRequest.bind(singleton),
AsynchronousFileManager,
totalStepCount
)

await singleton.finish()
const document = await singleton.regenerateDocument()
const deserializedDocument = deserialize(document) as AsynchronousFileDocument
await singleton.destroySuccessfully()

expect(deserializedDocument).toHaveProperty("data.finishedStepCount", totalStepCount)
expect(deserializedDocument).toHaveProperty("data.totalStepCount", totalStepCount)
expect(deserializedDocument).toHaveProperty("data.hasStopped", true)
expect(deserializedDocument).toHaveProperty("data.extra", { message })
})
})

0 comments on commit b551536

Please sign in to comment.