Skip to content

Commit

Permalink
Added test cases for token
Browse files Browse the repository at this point in the history
  • Loading branch information
lowdisk17 committed Nov 25, 2024
1 parent 153b664 commit 881378c
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/unit/tokenApi.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* eslint-disable @typescript-eslint/no-unused-expressions */
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck test suite
import chai from 'chai';
import tokenService from '../../src/services/tokenService';
import tokenApi from '../../src/apiServices/tokenApi';
import sinon from 'sinon';
import httpMocks from 'node-mocks-http';

const { expect, assert } = chai;

describe('Token API', function () {
describe('Token API: Correctly verifies asset data', function () {
afterEach(function () {
sinon.restore();
});

it('should return getTokenInfo successful result if value is valid', async function () {
const request = httpMocks.createRequest({
method: 'GET',
url: 'test',
params: {
network: "eth",
address: "0x455e53cbb86018ac2b8092fdcd39d8444affc3f6"
}
});
await sinon
.stub(tokenApi, 'getTokenInfo')
.returns({
decimal: "18",
logo: "http://eth.svg",
name: "Ethereum",
symbol: "eth"
});
const response = httpMocks.createResponse({
eventEmiiter: require('events').EventEmitter,
req: request,
});
const res = await tokenApi.getTokenInfo(request, res);
expect(res).to.have.property('decimal');
expect(res).to.have.property('logo');
expect(res).to.have.property('name');
expect(res).to.have.property('symbol');
});
});
});

0 comments on commit 881378c

Please sign in to comment.