Skip to content

Commit

Permalink
refactor(core-api): format timestamp of locks (#3091)
Browse files Browse the repository at this point in the history
  • Loading branch information
dated authored and spkjp committed Nov 21, 2019
1 parent f961d05 commit b96bb49
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion __tests__/integration/core-api/handlers/locks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ describe("API 2.0 - Locks", () => {

const lock = response.data.data[0];
api.expectLock(lock);
expect(lock.timestamp).toBe(5000);
expect(lock.timestamp.unix).toBe(1490106200);
expect(lock.timestamp.epoch).toBe(5000);
expect(lock.timestamp.human).toBe("2017-03-21T14:23:20.000Z");
});
});

Expand Down
1 change: 1 addition & 0 deletions __tests__/integration/core-api/handlers/wallets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ describe("API 2.0 - Wallets", () => {
type: j % 2 === 0 ? 1 : 2,
value: 100 * (j + 1),
},
timestamp: 0,
};
}

Expand Down
3 changes: 2 additions & 1 deletion packages/core-api/src/resources/lock.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Container } from "@arkecosystem/core-kernel";
import { Container, Utils } from "@arkecosystem/core-kernel";

import { Resource } from "../interfaces";

Expand Down Expand Up @@ -26,6 +26,7 @@ export class LockResource implements Resource {
return {
...resource,
amount: resource.amount.toFixed(),
timestamp: Utils.formatTimestamp(resource.timestamp),
};
}
}
5 changes: 4 additions & 1 deletion packages/core-test-framework/src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,12 @@ export class ApiHelpers {
expect(lock).toHaveProperty("recipientId");
expect(lock).toHaveProperty("amount");
expect(lock).toHaveProperty("secretHash");
expect(lock).toHaveProperty("timestamp");
expect(lock).toHaveProperty("expirationType");
expect(lock).toHaveProperty("expirationValue");
expect(lock.timestamp).toBeObject();
expect(lock.timestamp.epoch).toBeNumber();
expect(lock.timestamp.unix).toBeNumber();
expect(lock.timestamp.human).toBeString();
}

// todo: fix the use of the factory
Expand Down

0 comments on commit b96bb49

Please sign in to comment.