Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | 1x 1x 1x 1x 1x 1x 5x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | const { expect } = require(`chai`); const helper = require(`../helpers`), CoinpaymentsError = require(`../../lib/error`); let client, mock; before(function() { client = helper.getClient(); }); afterEach(function() { expect(mock.isDone()).equals(true); }); it(`Should handle error non json response callback`, function(done) { mock = helper.prepareMock(undefined, 1, `not-json`); client.rates(function(err) { expect(err).to.be.instanceOf(CoinpaymentsError); return done(); }); }); it(`Should handle error non json response promise`, function(done) { mock = helper.prepareMock(undefined, 1, `not-json`); client.rates().catch(function(err) { expect(err).to.be.instanceOf(CoinpaymentsError); return done(); }); }); it(`Should handle coinpayments error callback`, function(done) { mock = helper.prepareMock(undefined, 1, { code: 500, payload: { error: `error` } }); client.rates(function(err) { expect(err).to.be.instanceOf(CoinpaymentsError); return done(); }); }); it(`Should handle coinpayments error promise`, function(done) { mock = helper.prepareMock(undefined, 1, { code: 500, payload: { error: `error` } }); client.rates().catch(function(err) { expect(err).to.be.instanceOf(CoinpaymentsError); return done(); }); }); it(`Should have proper customer error implementation`, function () { const extra = { prop: 1 }; const err = new CoinpaymentsError(`My custom message`, extra); expect(err.name).equals(`CoinpaymentsError`); expect(err).to.be.instanceOf(CoinpaymentsError); expect(err).to.be.instanceOf(Error); expect(require(`util`).isError(err)).equals(true); expect(!!err.stack).equals(true); expect(err.toString()).equals(`CoinpaymentsError: My custom message`); expect(err.stack.split(`\n`)[0]).equals(`CoinpaymentsError: My custom message`); expect(err.extra).equals(extra); }); |