UNPKG

mares-apistore-message-error

Version:

apistore api호출시 필요한 error handling module 입니다.

94 lines (67 loc) 2.9 kB
const should = require('should'); const utils = require('./utils'); const MaresError = require('./'); const _ = require('lodash'); suite('Module MaresApistoreMessageError Test', () => { suiteSetup(async () => { }); suite('convertApistoreErrorToMaresError method', async () => { test('should convert apistore message error to invalid user mares error.', async () => { let error = { result_code: 100, result_msg: 'msg', cmid: Math.random() }; let refinedError = utils.convert('sendSMS', error); let obj = _.keyBy(refinedError.body.rows, 'code'); refinedError.should.have.property('status', 400); should.exist(obj[utils.codes.invalidUser]); }); test('should convert apistore message error to invalidParameter mares error.', async () => { let error = { result_code: 300, result_msg: 'msg', cmid: Math.random() }; let refinedError = utils.convert('sendSMS', error); let obj = _.keyBy(refinedError.body.rows, 'code'); refinedError.should.have.property('status', 400); should.exist(obj[utils.codes.invalidParameter]); }); test('should convert apistore message error to etc mares error.', async () => { let error = { result_code: 400, result_msg: 'msg', cmid: Math.random() }; let refinedError = utils.convert('sendSMS', error); let obj = _.keyBy(refinedError.body.rows, 'code'); refinedError.should.have.property('status', 400); should.exist(obj[utils.codes.etc]); }); test('should convert apistore message error to invalidRegistration mares error.', async () => { let error = { result_code: 500, result_msg: 'msg', cmid: Math.random() }; let refinedError = utils.convertApistoreErrorToMaresError('sendSMS', error); let obj = _.keyBy(refinedError.body.rows, 'code'); refinedError.should.have.property('status', 400); should.exist(obj[utils.codes.invalidRegistration]); }); test('should convert apistore message error to insufficient mares error.', async () => { let error = { result_code: 600, result_msg: 'msg', cmid: Math.random() }; let refinedError = utils.convert('sendSMS', error); let obj = _.keyBy(refinedError.body.rows, 'code'); refinedError.should.have.property('status', 400); should.exist(obj[utils.codes.insufficient]); }); }); suiteTeardown(() => { }); });