2020-10-27 11:27:17 +01:00
|
|
|
'use strict';
|
|
|
|
|
2019-08-08 10:41:05 +02:00
|
|
|
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 biginteger', () => {
|
|
|
|
beforeAll(async () => {
|
|
|
|
const token = await registerAndLogin();
|
|
|
|
rq = createAuthRequest(token);
|
|
|
|
|
|
|
|
modelsUtils = createModelsUtils({ rq });
|
|
|
|
|
2019-12-12 10:15:25 +01:00
|
|
|
await modelsUtils.createContentTypeWithType('withbiginteger', 'biginteger');
|
2019-08-08 10:41:05 +02:00
|
|
|
}, 60000);
|
|
|
|
|
|
|
|
afterAll(async () => {
|
2019-12-12 10:15:25 +01:00
|
|
|
await modelsUtils.deleteContentType('withbiginteger');
|
2019-08-08 10:41:05 +02:00
|
|
|
}, 60000);
|
|
|
|
|
|
|
|
test('Create entry with value input JSON', async () => {
|
2019-08-08 14:29:09 +02:00
|
|
|
const inputValue = '1223372036854775';
|
2019-11-15 11:49:32 +01:00
|
|
|
const res = await rq.post(
|
2020-11-02 12:40:35 +01:00
|
|
|
'/content-manager/collection-types/application::withbiginteger.withbiginteger',
|
2019-11-15 11:49:32 +01:00
|
|
|
{
|
|
|
|
body: {
|
|
|
|
field: inputValue,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
2019-08-08 10:41:05 +02:00
|
|
|
|
|
|
|
expect(res.statusCode).toBe(200);
|
|
|
|
expect(res.body).toMatchObject({
|
|
|
|
field: inputValue,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Create entry with value input Formdata', async () => {
|
2019-08-08 14:29:09 +02:00
|
|
|
const inputValue = '1223372036854775';
|
2019-11-15 11:49:32 +01:00
|
|
|
const res = await rq.post(
|
2020-11-02 12:40:35 +01:00
|
|
|
'/content-manager/collection-types/application::withbiginteger.withbiginteger',
|
2019-11-15 11:49:32 +01:00
|
|
|
{
|
|
|
|
formData: {
|
|
|
|
data: JSON.stringify({ field: inputValue }),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
2019-08-08 10:41:05 +02:00
|
|
|
|
|
|
|
expect(res.statusCode).toBe(200);
|
|
|
|
expect(res.body).toMatchObject({
|
|
|
|
field: inputValue,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Create entry with integer should return a string', async () => {
|
|
|
|
const inputValue = 1821;
|
2019-11-15 11:49:32 +01:00
|
|
|
const res = await rq.post(
|
2020-11-02 12:40:35 +01:00
|
|
|
'/content-manager/collection-types/application::withbiginteger.withbiginteger',
|
2019-11-15 11:49:32 +01:00
|
|
|
{
|
|
|
|
body: {
|
|
|
|
field: inputValue,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
2019-08-08 10:41:05 +02:00
|
|
|
|
|
|
|
expect(res.statusCode).toBe(200);
|
|
|
|
expect(res.body).toMatchObject({
|
|
|
|
field: `${inputValue}`,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Reading entry, returns correct value', async () => {
|
2019-11-15 11:49:32 +01:00
|
|
|
const res = await rq.get(
|
2020-11-02 12:40:35 +01:00
|
|
|
'/content-manager/collection-types/application::withbiginteger.withbiginteger'
|
2019-11-15 11:49:32 +01:00
|
|
|
);
|
2019-08-08 10:41:05 +02:00
|
|
|
|
|
|
|
expect(res.statusCode).toBe(200);
|
|
|
|
expect(Array.isArray(res.body)).toBe(true);
|
|
|
|
res.body.forEach(entry => {
|
|
|
|
expect(entry.field).toEqual(expect.any(String));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Updating entry sets the right value and format', async () => {
|
2019-08-08 14:29:09 +02:00
|
|
|
const inputValue = '1223372036854775';
|
2019-11-15 11:49:32 +01:00
|
|
|
const res = await rq.post(
|
2020-11-02 12:40:35 +01:00
|
|
|
'/content-manager/collection-types/application::withbiginteger.withbiginteger',
|
2019-11-15 11:49:32 +01:00
|
|
|
{
|
|
|
|
body: {
|
|
|
|
field: inputValue,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
2019-08-08 10:41:05 +02:00
|
|
|
|
|
|
|
const newVal = '9882823782712112';
|
|
|
|
const updateRes = await rq.put(
|
2020-11-02 12:40:35 +01:00
|
|
|
`/content-manager/collection-types/application::withbiginteger.withbiginteger/${res.body.id}`,
|
2019-08-08 10:41:05 +02:00
|
|
|
{
|
|
|
|
body: {
|
|
|
|
field: newVal,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(updateRes.statusCode).toBe(200);
|
|
|
|
expect(updateRes.body).toMatchObject({
|
|
|
|
id: res.body.id,
|
|
|
|
field: newVal,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|