2018-05-21 17:04:25 +02:00
|
|
|
const axios = require('axios');
|
2018-05-18 14:22:24 +02:00
|
|
|
|
2018-05-21 17:04:25 +02:00
|
|
|
const request = axios.create({
|
|
|
|
baseURL: 'http://localhost:1337',
|
|
|
|
});
|
2018-05-18 14:22:24 +02:00
|
|
|
|
2018-05-21 17:04:25 +02:00
|
|
|
const params = require('./helper/generators');
|
|
|
|
const restart = require('./helper/restart');
|
2018-05-18 14:22:24 +02:00
|
|
|
|
2018-05-21 17:04:25 +02:00
|
|
|
describe('App setup auth', () => {
|
|
|
|
test(
|
|
|
|
'Register admin user',
|
|
|
|
async () => {
|
|
|
|
const body = await request.post('/auth/local/register', {
|
|
|
|
username: 'admin',
|
|
|
|
email: 'admin@strapi.io',
|
|
|
|
password: 'pcw123'
|
2018-05-18 14:22:24 +02:00
|
|
|
});
|
|
|
|
|
2018-05-21 17:04:25 +02:00
|
|
|
axios.defaults.headers.common['Authorization'] = `Bearer ${body.data.jwt}`;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2018-05-18 14:22:24 +02:00
|
|
|
|
2018-05-21 17:04:25 +02:00
|
|
|
describe('Generate test APIs', () => {
|
|
|
|
beforeEach(async () => {
|
|
|
|
await restart(request);
|
|
|
|
}, 60000);
|
2018-05-18 14:22:24 +02:00
|
|
|
|
2018-05-21 17:04:25 +02:00
|
|
|
test(
|
|
|
|
'Create new article API',
|
|
|
|
async () => {
|
|
|
|
await request.post('/content-type-builder/models', params.article);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
'Create new tag API',
|
|
|
|
async () => {
|
|
|
|
await request.post('/content-type-builder/models', params.tag);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
test(
|
|
|
|
'Create new category API',
|
|
|
|
async () => {
|
|
|
|
await request.post('/content-type-builder/models', params.category);
|
|
|
|
}
|
2018-05-18 14:22:24 +02:00
|
|
|
);
|
|
|
|
});
|