feat(M08-A): 接入顾客端权益明细
This commit is contained in:
@@ -13,6 +13,7 @@ const forbiddenToken = signAccessToken({
|
||||
}, secret, 900);
|
||||
|
||||
let profileInput;
|
||||
let benefitsInput;
|
||||
const app = await buildApp({
|
||||
members: {
|
||||
jwtSecret: secret,
|
||||
@@ -46,6 +47,23 @@ const app = await buildApp({
|
||||
service: {
|
||||
async listMembers() { throw new Error('not called'); },
|
||||
async getMember() { throw new Error('not called'); },
|
||||
async getMyBenefits(input) {
|
||||
benefitsInput = input;
|
||||
return {
|
||||
coupons: [{
|
||||
couponGrantId: '401',
|
||||
name: '30元抵扣券',
|
||||
status: 'AVAILABLE',
|
||||
discountAmountCents: 3000
|
||||
}],
|
||||
packages: [{
|
||||
packageHoldingId: '501',
|
||||
name: '三小时畅玩包',
|
||||
status: 'ACTIVE',
|
||||
remainingMinutes: 120
|
||||
}]
|
||||
};
|
||||
},
|
||||
async getMyProfile(input) {
|
||||
profileInput = input;
|
||||
return {
|
||||
@@ -71,6 +89,17 @@ assert.equal(profileInput.tenantId, '7');
|
||||
assert.equal(profileInput.userId, '21');
|
||||
assert.equal(profile.json().data.wallet.totalBalanceCents, 1200);
|
||||
|
||||
const benefits = await app.inject({
|
||||
method: 'GET',
|
||||
url: '/app-api/profile/benefits',
|
||||
headers: { authorization: `Bearer ${token}` }
|
||||
});
|
||||
assert.equal(benefits.statusCode, 200);
|
||||
assert.equal(benefitsInput.tenantId, '7');
|
||||
assert.equal(benefitsInput.userId, '21');
|
||||
assert.equal(benefits.json().data.coupons[0].couponGrantId, '401');
|
||||
assert.equal(benefits.json().data.packages[0].packageHoldingId, '501');
|
||||
|
||||
const unauthorized = await app.inject({
|
||||
method: 'GET',
|
||||
url: '/app-api/profile'
|
||||
|
||||
Reference in New Issue
Block a user