mirror of
https://github.com/strapi/strapi.git
synced 2025-12-12 15:32:42 +00:00
add test to support trimming
This commit is contained in:
parent
4b7a1eb48f
commit
e16ce91ade
@ -14,7 +14,9 @@ module.exports = {
|
||||
* - having only spaces as value;
|
||||
*/
|
||||
attributes.name = attributes.name.trim();
|
||||
attributes.description = attributes.description.trim();
|
||||
if (attributes.description) {
|
||||
attributes.description = attributes.description.trim();
|
||||
}
|
||||
|
||||
try {
|
||||
await validateApiTokenCreationInput(attributes);
|
||||
|
||||
@ -12,6 +12,7 @@ const { createAuthRequest } = require('../../../../../test/helpers/request');
|
||||
* 2. Fails to creates an api token (invalid `type` in the body)
|
||||
* 3. Creates an api token (successfully)
|
||||
* 4. Creates an api token without a description (successfully)
|
||||
* 5. Creates an api token with trimmed description and name (successfully)
|
||||
*/
|
||||
|
||||
describe('Admin API Token CRUD (e2e)', () => {
|
||||
@ -120,4 +121,27 @@ describe('Admin API Token CRUD (e2e)', () => {
|
||||
id: expect.any(Number),
|
||||
});
|
||||
});
|
||||
|
||||
test('5. Creates an api token with trimmed description and name (successfully)', async () => {
|
||||
const body = {
|
||||
name: 'api-token_tests-name-with-spaces-at-the-end ',
|
||||
description: 'api-token_tests-description-with-spaces-at-the-end ',
|
||||
type: 'read-only',
|
||||
};
|
||||
|
||||
const res = await rq({
|
||||
url: '/admin/api-tokens',
|
||||
method: 'POST',
|
||||
body,
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(201);
|
||||
expect(res.body.data).toMatchObject({
|
||||
accessKey: expect.any(String),
|
||||
name: 'api-token_tests-name-with-spaces-at-the-end',
|
||||
description: 'api-token_tests-description-with-spaces-at-the-end',
|
||||
type: body.type,
|
||||
id: expect.any(Number),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user