Skip to content

Commit

Permalink
Update tests and mocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Cardona committed Feb 22, 2019
1 parent badf84c commit 6272f7b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,35 @@ describe("#Utils", () => {
])
assert.equal(list.id, tokenId)
})

it(`should list multople SLP tokens by array of ids`, async () => {
// Mock the call to rest.bitcoin.com
if (process.env.TEST === "unit") {
nock(SERVER)
.post(uri => uri.includes("/"))
.reply(200, mockData.mockTokens)
}

const tokenIds = [
"4276533bb702e7f8c9afd8aa61ebf016e95011dc3d54e55faa847ac1dd461e84",
"b3f4f132dc3b9c8c96316346993a8d54d729715147b7b11aa6c8cd909e955313"
]

const list = await SLP.Utils.list(tokenIds)
// console.log(`list: ${JSON.stringify(list, null, 2)}`)

assert2.hasAllKeys(list[0], [
"id",
"timestamp",
"symbol",
"name",
"documentUri",
"documentHash",
"decimals",
"initialTokenQty"
])
assert.equal(list[0].id, tokenIds[0])
})
})

describe("#balancesForAddress", () => {
Expand Down
24 changes: 24 additions & 0 deletions test/fixtures/mock-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,29 @@ const mockToken = {
initialTokenQty: 10000000000000000
}

const mockTokens = [
{
id: "4276533bb702e7f8c9afd8aa61ebf016e95011dc3d54e55faa847ac1dd461e84",
timestamp: "2018-08-25 03:54",
symbol: "USDT",
name: "US Dollar Tether",
documentUri: "",
documentHash: "",
decimals: 0,
initialTokenQty: 10000000000000000
},
{
id: "b3f4f132dc3b9c8c96316346993a8d54d729715147b7b11aa6c8cd909e955313",
timestamp: "2019-01-30 21:56",
symbol: "SLPJS",
name: "Awesome SLPJS README Token",
documentUri: "[email protected]",
documentHash: "",
decimals: 2,
initialTokenQty: 1000000
}
]

const balancesForAddress = [
{
tokenId: "df808a41672a0a0ae6475b44f272a107bc9961b90f29dc918d71301f24fe92fb",
Expand Down Expand Up @@ -95,6 +118,7 @@ const mockIsValidTxid = [
module.exports = {
mockList,
mockToken,
mockTokens,
balancesForAddress,
mockRawTx,
mockIsValidTxid
Expand Down

0 comments on commit 6272f7b

Please sign in to comment.