55 lines
1.1 KiB
JavaScript
Raw Normal View History

'use strict';
// Test a simple default API with no relations
2021-04-29 11:11:46 +02:00
const { createStrapiInstance } = require('../../../../test/helpers/strapi');
const { createAuthRequest } = require('../../../../test/helpers/request');
let strapi;
let rq;
let data = {};
describe('Users API', () => {
beforeAll(async () => {
strapi = await createStrapiInstance();
rq = await createAuthRequest({ strapi });
});
afterAll(async () => {
await strapi.destroy();
});
test('Create User', async () => {
const user = {
username: 'User 1',
email: 'user1@strapi.io',
password: 'test1234',
};
const res = await rq({
method: 'POST',
url: '/auth/local/register',
body: user,
});
expect(res.statusCode).toBe(200);
expect(res.body).toMatchObject({
jwt: expect.any(String),
user: {
username: user.username,
email: user.email,
},
});
data.user = res.body.user;
});
test('Delete user', async () => {
const res = await rq({
method: 'DELETE',
url: `/users/${data.user.id}`,
});
expect(res.statusCode).toBe(200);
});
});