Add simple test for the password encryption

This commit is contained in:
Convly 2021-10-12 16:39:09 +02:00
parent 33611a9323
commit c1ba9af7c0

View File

@ -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',
});
});
});
});