From 7105a586a97cded5a81a3352b97a89875fa0a903 Mon Sep 17 00:00:00 2001 From: Bartek Wrona Date: Wed, 5 Jun 2024 22:26:30 +0200 Subject: [PATCH] Added test to verify correct behavior when converting negative assets --- wasm/__tests__/detailed/hive_base.ts | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/wasm/__tests__/detailed/hive_base.ts b/wasm/__tests__/detailed/hive_base.ts index f382277d..ca385ddf 100644 --- a/wasm/__tests__/detailed/hive_base.ts +++ b/wasm/__tests__/detailed/hive_base.ts @@ -28,6 +28,55 @@ test.describe('Wax object interface foundation tests', () => { await page.goto("http://localhost:8080/wasm/__tests__/assets/test.html", { waitUntil: "load" }); }); + test('Should be able to generate negative HIVE asset', async ({ waxTest }) => { + const retVal = await waxTest(async({ base }) => { + return base.hive(-300_000); + }); + + expect(retVal).toStrictEqual({ + amount: "-300000", + nai: "@@000000021", + precision: 3 + }); + }); + + test('Should be able to generate negative HBD asset', async ({ waxTest }) => { + const retVal = await waxTest(async({ base }) => { + return base.hbd(-300_000); + }); + + expect(retVal).toStrictEqual({ + amount: "-300000", + nai: "@@000000013", + precision: 3 + }); + }); + + test('Should be able to generate negative VESTS asset', async ({ waxTest }) => { + const retVal = await waxTest(async({ base }) => { + return base.vests(-300_000000); + }); + + expect(retVal).toStrictEqual({ + amount: "-300000000", + nai: "@@000000037", + precision: 6 + }); + }); + + test('Should be able to convert API asset to the proper negative HIVE asset data', async ({ waxTest }) => { + const retVal = await waxTest(async({ base }, naiAsset) => { + const asset = base.getAsset({ ...naiAsset, amount: `-${naiAsset.amount}` }); + + return asset; + }, naiAsset); + + expect(retVal).toStrictEqual({ + amount: "-300.000", + symbol: "HIVE" + }); + }); + test('Should be able to convert API asset to the proper HIVE asset data', async ({ waxTest }) => { const retVal = await waxTest(async({ base }, naiAsset) => { const asset = base.getAsset(naiAsset);