mirror of
https://github.com/strapi/strapi.git
synced 2025-08-30 11:45:48 +00:00
fix: tests and logging
This commit is contained in:
parent
8263926b47
commit
17f8ef0d9b
@ -338,7 +338,6 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
console.log('params', params);
|
||||
const newUser = {
|
||||
...params,
|
||||
role: role.id,
|
||||
@ -351,7 +350,6 @@ module.exports = {
|
||||
|
||||
const sanitizedUser = await sanitizeUser(user, ctx);
|
||||
|
||||
console.log('sanitizedUser', sanitizedUser);
|
||||
if (settings.email_confirmation) {
|
||||
try {
|
||||
await getService('user').sendConfirmationEmail(sanitizedUser);
|
||||
|
@ -15,7 +15,7 @@ const mockStrapi = {
|
||||
get: jest.fn(() => {
|
||||
return {
|
||||
register: {
|
||||
allowedFields: [],
|
||||
// only set allowedFields on a per-test basis
|
||||
},
|
||||
};
|
||||
}),
|
||||
@ -74,7 +74,7 @@ describe('user-permissions auth', () => {
|
||||
});
|
||||
|
||||
describe('register', () => {
|
||||
test('accepts valid body', async () => {
|
||||
test('accepts valid registration', async () => {
|
||||
const ctx = {
|
||||
state: {
|
||||
auth: {},
|
||||
@ -89,7 +89,8 @@ describe('user-permissions auth', () => {
|
||||
expect(ctx.send).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test("throws ValidationError when given fields that aren't allowed", async () => {
|
||||
test('throws ValidationError when passed fields not in allowedFields', async () => {
|
||||
// without allowedFields
|
||||
const ctx = {
|
||||
state: {
|
||||
auth: {},
|
||||
@ -106,6 +107,22 @@ describe('user-permissions auth', () => {
|
||||
};
|
||||
await expect(auth.register(ctx)).rejects.toThrow(errors.ValidationError);
|
||||
|
||||
// with allowedFields []
|
||||
global.strapi = {
|
||||
...mockStrapi,
|
||||
config: {
|
||||
get: jest.fn(() => {
|
||||
return {
|
||||
register: {
|
||||
allowedFields: [],
|
||||
},
|
||||
};
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
||||
await expect(auth.register(ctx)).rejects.toThrow(errors.ValidationError);
|
||||
|
||||
expect(ctx.send).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
@ -122,6 +139,7 @@ describe('user-permissions auth', () => {
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
||||
const ctx = {
|
||||
state: {
|
||||
auth: {},
|
||||
|
Loading…
x
Reference in New Issue
Block a user