mirror of
https://github.com/strapi/strapi.git
synced 2025-12-25 22:23:10 +00:00
Add email tests
This commit is contained in:
parent
d468033b8e
commit
93c7f63cd1
@ -1,7 +1,86 @@
|
||||
const { registerAndLogin } = require('../../../../test/helpers/auth');
|
||||
const createModelsUtils = require('../../../../test/helpers/models');
|
||||
const { createAuthRequest } = require('../../../../test/helpers/request');
|
||||
|
||||
let modelsUtils;
|
||||
let rq;
|
||||
|
||||
describe('Test type email', () => {
|
||||
test.todo('Create entry with valid value');
|
||||
beforeAll(async () => {
|
||||
const token = await registerAndLogin();
|
||||
rq = createAuthRequest(token);
|
||||
|
||||
test.todo('Reading entry, returns correct value');
|
||||
modelsUtils = createModelsUtils({ rq });
|
||||
|
||||
test.todo('Updating entry sets the right value and format');
|
||||
await modelsUtils.createModelWithType('withemail', 'email');
|
||||
}, 60000);
|
||||
|
||||
afterAll(async () => {
|
||||
await modelsUtils.deleteModel('withemail');
|
||||
}, 60000);
|
||||
|
||||
test('Create entry with value input JSON', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withemail', {
|
||||
body: {
|
||||
field: 'someemail',
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
field: 'someemail',
|
||||
});
|
||||
});
|
||||
|
||||
test.todo('Should Throw on invalid email');
|
||||
|
||||
test('Create entry with value input Formdata', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withemail', {
|
||||
body: {
|
||||
field: 1234567,
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(res.body).toMatchObject({
|
||||
field: '1234567',
|
||||
});
|
||||
});
|
||||
|
||||
test('Reading entry returns correct value', async () => {
|
||||
const res = await rq.get('/content-manager/explorer/withemail');
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(Array.isArray(res.body)).toBe(true);
|
||||
expect(res.body).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
field: expect.any(String),
|
||||
}),
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
test('Updating entry sets the right value and format', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withemail', {
|
||||
body: {
|
||||
field: 'someemail',
|
||||
},
|
||||
});
|
||||
|
||||
const updateRes = await rq.put(
|
||||
`/content-manager/explorer/withemail/${res.body.id}`,
|
||||
{
|
||||
body: {
|
||||
field: 'otherPwd',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(updateRes.statusCode).toBe(200);
|
||||
expect(updateRes.body).toMatchObject({
|
||||
id: res.body.id,
|
||||
field: 'otherPwd',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -32,6 +32,8 @@ describe('Test type password', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test.todo('Should be private by default');
|
||||
|
||||
test('Create entry with value input Formdata', async () => {
|
||||
const res = await rq.post('/content-manager/explorer/withpassword', {
|
||||
body: {
|
||||
|
||||
@ -66,7 +66,7 @@ const generateTestApp = async ({ appName, database }) => {
|
||||
* @param {string} options.appName - Name of the app / folder in which run the start script
|
||||
*/
|
||||
const startTestApp = ({ appName }) => {
|
||||
return execa.shell('strapi develop --no-build', {
|
||||
return execa.shell('BROWSER=none strapi develop --no-build', {
|
||||
stdio: 'inherit',
|
||||
cwd: path.resolve(appName),
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user