From d864dfd899ea56f5a5f19ba2f65de4619cdf6656 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 20 Dec 2023 06:45:40 +0100 Subject: [PATCH] refs #5878 test: init test --- .../middleware/specs/value-is-not.spec.js | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 loopback/server/middleware/specs/value-is-not.spec.js diff --git a/loopback/server/middleware/specs/value-is-not.spec.js b/loopback/server/middleware/specs/value-is-not.spec.js new file mode 100644 index 000000000..b9d15f2aa --- /dev/null +++ b/loopback/server/middleware/specs/value-is-not.spec.js @@ -0,0 +1,47 @@ +const valueIsNot = require('../value-is-not'); + +fdescribe('Value is not', () => { + const i18n = require('i18n'); + + const userId = 9; + const ctx = { + req: { + + accessToken: {userId: userId}, + headers: {origin: 'http://localhost:5000'}, + } + }; + + it('UpdateFiscalData endpoint', () => { + let messageError = 'Value is not number'; + const tag = 'provinceFk'; + try { + expect(valueIsNot.validation(messageError)).toBeTrue(); + expect(valueIsNot.message(i18n, tag)).toEqual('El campo \'Provincia\' no es válido'); + const data = { + method: 'POST', + originalUrl: 'updateFiscalData', + body: { + [tag]: null + } + }; + const result = valueIsNot.handleError(data); + + expect(result).toEqual(tag); + } catch (error) { + expect(error).toBeDefined(); + } + }); + + describe('OsTicket', () => { + let messageError = 'Value is not number'; + it('sendToSupport endpoint', () => { + try { + expect(valueIsNot.validation(messageError)).toBeTrue(); + expect(valueIsNot.message(ctx, 'provinceFk')).toEqual('El campo "Provincia" no es válido'); + } catch (error) { + expect(error).toBeDefined(); + } + }); + }); +});