feat: 订单获取链路收尾:管理端指派、接单开关与用户指定陪诊师
This commit is contained in:
@@ -61,13 +61,15 @@ function createCtx({ body = {}, query = {}, user, params = { id: RECORD_ID } } =
|
||||
};
|
||||
}
|
||||
|
||||
function employeeFindOneStub(employee) {
|
||||
function employeeFindOneStub(employee, overrides = {}) {
|
||||
return {
|
||||
findOne: () => ({
|
||||
select: () => ({
|
||||
lean: () => ({ exec: async () => employee }),
|
||||
}),
|
||||
}),
|
||||
incrementOrderCount: async () => {},
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -186,6 +188,7 @@ test("实习陪诊师不能接单", async () => {
|
||||
|
||||
test("正式陪诊师接单写入陪诊师快照,不校验支付状态", async () => {
|
||||
let payload = null;
|
||||
let bumped = null;
|
||||
const record = buildRecord();
|
||||
const recordStub = {
|
||||
findById: async () => record,
|
||||
@@ -198,18 +201,26 @@ test("正式陪诊师接单写入陪诊师快照,不校验支付状态", async
|
||||
},
|
||||
};
|
||||
|
||||
await withModel("Employee", employeeFindOneStub(buildEmployee()), () =>
|
||||
withModel("EscortRecord", recordStub, async () => {
|
||||
const ctx = createCtx({ user: { _id: CERT_USER_ID } });
|
||||
await new HandlerEscortRecord().acceptRecord(ctx);
|
||||
await withModel(
|
||||
"Employee",
|
||||
employeeFindOneStub(buildEmployee(), {
|
||||
incrementOrderCount: async (employeeId) => {
|
||||
bumped = employeeId;
|
||||
},
|
||||
}),
|
||||
() =>
|
||||
withModel("EscortRecord", recordStub, async () => {
|
||||
const ctx = createCtx({ user: { _id: CERT_USER_ID } });
|
||||
await new HandlerEscortRecord().acceptRecord(ctx);
|
||||
|
||||
assert.equal(ctx.body.code, 0);
|
||||
assert.equal(payload.id, CERT_USER_ID);
|
||||
assert.equal(payload.name, "李四");
|
||||
assert.equal(payload.sex, "male");
|
||||
assert.equal(payload.mobile, "13700137000");
|
||||
assert.equal(ctx.body.data.record.attendantAssignedToMe, true);
|
||||
})
|
||||
assert.equal(ctx.body.code, 0);
|
||||
assert.equal(payload.id, CERT_USER_ID);
|
||||
assert.equal(payload.name, "李四");
|
||||
assert.equal(payload.sex, "male");
|
||||
assert.equal(payload.mobile, "13700137000");
|
||||
assert.equal(ctx.body.data.record.attendantAssignedToMe, true);
|
||||
assert.equal(bumped, CERT_EMPLOYEE_ID);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user