Skip to content

Commit

Permalink
fix: feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
shuffledex committed Mar 11, 2020
1 parent 4f70fbd commit b1fdd1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/api/procedures/__tests__/reserveTicker.ts
Expand Up @@ -173,7 +173,7 @@ describe('reserveTicker procedure', () => {
);
});

test('should throw an error if extendPeriod property is set to true and the ticker has already been launched', async () => {
test('should throw an error if extendPeriod property is set to true and the token has already been launched', async () => {
const expiryDate = null;
mockTickerReservation.mock('details', {
ownerDid: 'someDid',
Expand All @@ -187,17 +187,18 @@ describe('reserveTicker procedure', () => {
);
});

test('should throw an error if extendPeriod property is set to true and the ticker has already expired', async () => {
test('should throw an error if extendPeriod property is set to true and the ticker has not reserved or the reservation has expired', async () => {
const expiryDate = new Date(2019, 1, 1);
mockTickerReservation.mock('details', {
ownerDid: 'someDid',
expiryDate,
status: TickerReservationStatus.Free,
});
const proc = mockProcedure.getMockInstance();
proc.context = mockContext;

return expect(prepareReserveTicker.call(proc, { ...args, extendPeriod: true })).rejects.toThrow(
'Ticker has already expired'
'Ticker not reserved or the reservation has expired'
);
});

Expand Down
4 changes: 2 additions & 2 deletions src/api/procedures/reserveTicker.ts
Expand Up @@ -93,10 +93,10 @@ export async function prepareReserveTicker(
});
}

if (expiryDate < new Date()) {
if (status === TickerReservationStatus.Free) {
throw new PolymeshError({
code: ErrorCode.ValidationError,
message: 'Ticker has already expired',
message: 'Ticker not reserved or the reservation has expired',
});
}
}
Expand Down

0 comments on commit b1fdd1e

Please sign in to comment.