Skip to content

Commit

Permalink
Added a few tests to increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mcanever committed Sep 8, 2018
1 parent c374e8d commit 3481fe4
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion tests/unit/apis/requests/PostBlocksRequest.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import * as sinon from 'sinon';
import { SinonSandbox } from 'sinon';
import { SinonSandbox, SinonStub } from 'sinon';
import { PostBlocksRequest } from '../../../../src/apis/requests/PostBlocksRequest';
import { Symbols } from '../../../../src/ioc/symbols';
import { ProtoBufHelperStub } from '../../../stubs/helpers/ProtoBufHelperStub';
Expand Down Expand Up @@ -89,6 +89,33 @@ describe('apis/requests/PostBlocksRequest', () => {
});
});

describe('getResponseData', () => {
let supportsStub: SinonStub;
let decodeStub: SinonStub;
beforeEach(() => {
supportsStub = sandbox.stub();
decodeStub = sandbox.stub().returns('decodedValue');
(instance as any).peerSupportsProtoBuf = supportsStub;
(instance as any).decodeProtoBufResponse = decodeStub;
});

describe('protoBuf = false', () => {
it('should return the response body', () => {
supportsStub.returns(false);
const ret = instance.getResponseData({body: 'responseBody'});
expect(ret).to.be.equal('responseBody');
});
});
describe('protoBuf = true', () => {
it('should return the decoded response body', () => {
supportsStub.returns(true);
decodeStub.returns('decodedValue');
const ret = instance.getResponseData({body: 'requestBody'});
expect(ret).to.be.equal('decodedValue');
});
});
});

// TODO: Move this test to APIRequest
/*
describe('generateBytesBlock()', () => {
Expand Down

0 comments on commit 3481fe4

Please sign in to comment.