Skip to content

Commit

Permalink
test(content-type): add test for private option in relation field
Browse files Browse the repository at this point in the history
Signed-off-by: tanmoyopenroot <tanmoy.openroot@gmail.com>
  • Loading branch information
tanmoyopenroot committed Oct 2, 2020
1 parent 668784a commit c038428
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import fields from '../forms';

describe('forms', () => {
it('should contain private field in relation input type', () => {
const { items } = fields.attribute.form.advanced({}, 'relation', null);

expect(
items.find(relationItem => relationItem.find(item => item.name === 'private')).length
).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,47 @@ describe('Content Type Builder - Content types', () => {
expect(updateRes.body.error).toMatch('multiple entries in DB');
});
});

describe('Private relation field', () => {
const singleTypeUID = 'application::test-single-type.test-single-type';

test('should add a relation field', async () => {
const res = await rq({
method: 'PUT',
url: `/content-type-builder/content-types/${singleTypeUID}`,
body: {
contentType: {
kind: 'singleType',
name: 'test-collection',
attributes: {
relation: {
private: true,
nature: 'oneWay',
target: 'plugins::users-permissions.user',
targetAttribute: 'test',
},
},
},
},
});

expect(res.statusCode).toBe(201);
expect(res.body).toEqual({
data: {
uid: singleTypeUID,
},
});
});

test('should contain a private relation field', async () => {
const res = await rq({
method: 'GET',
url: `/content-type-builder/content-types/${singleTypeUID}`,
});

expect(res.statusCode).toBe(200);
expect(res.body.data.schema.attributes.relation).toBeDefined();
expect(res.body.data.schema.attributes.relation.private).toBeTruthy();
});
});
});

0 comments on commit c038428

Please sign in to comment.