From c1ba9af7c03c38f117d7af89215fb6f771e15dfc Mon Sep 17 00:00:00 2001 From: Convly Date: Tue, 12 Oct 2021 16:39:09 +0200 Subject: [PATCH] Add simple test for the password encryption --- .../entity-service/__tests__/entity-service.test.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/core/strapi/lib/services/entity-service/__tests__/entity-service.test.js b/packages/core/strapi/lib/services/entity-service/__tests__/entity-service.test.js index 0446020768..6428d053dc 100644 --- a/packages/core/strapi/lib/services/entity-service/__tests__/entity-service.test.js +++ b/packages/core/strapi/lib/services/entity-service/__tests__/entity-service.test.js @@ -1,5 +1,7 @@ 'use strict'; +jest.mock('bcrypt', () => ({ hashSync: () => 'secret-password' })); + const { EventEmitter } = require('events'); const createEntityService = require('../'); const entityValidator = require('../../entity-validator'); @@ -109,6 +111,7 @@ describe('Entity service', () => { enum: ['a', 'b', 'c'], default: 'b', }, + attrPassword: { type: 'password' }, }, }; @@ -173,9 +176,13 @@ describe('Entity service', () => { attrIntDefault: 10, attrEnumDefaultRequired: 'c', attrEnumDefault: 'a', + attrPassword: 'fooBar', }; - await expect(instance.create('test-model', { data })).resolves.toMatchObject(data); + await expect(instance.create('test-model', { data })).resolves.toMatchObject({ + ...data, + attrPassword: 'secret-password', + }); }); }); });