mirror of
https://github.com/directus/directus.git
synced 2026-02-19 10:14:33 -05:00
* add new sdk * update version * fixes and sdk documentation * typing updates, documentation * added missing endpoints * targeting minified version for unpkg * removed unused types file * fixed non minified versions * fix sdk exports * fix the fix * Remove old sdk * Remove old sdk docs * Install types for Jest, add npm test * Rely on npm exclusively * Remove examples folder * Move typescript down * Update sdk.md * added auto refresh and requested changes added more http test calls fixed typing issue in customized types * remove unused endpoint * updated docs * added singletons, fixed typing issues, added password handlers * rename graphql function and fixed system endpoint * Remove unused imports, fix build Co-authored-by: rijkvanzanten <rijkvanzanten@me.com> Co-authored-by: Ben Haynes <ben@rngr.org>
65 lines
1.3 KiB
TypeScript
65 lines
1.3 KiB
TypeScript
/**
|
|
* @jest-environment node
|
|
*/
|
|
|
|
import { Directus } from '../../src';
|
|
import { test } from '../utils';
|
|
|
|
describe('comments', function () {
|
|
test(`creates comments`, async (url, nock) => {
|
|
nock()
|
|
.post('/activity/comment', {
|
|
collection: 'posts',
|
|
item: '1',
|
|
comment: 'Awesome post!',
|
|
})
|
|
.reply(200, {
|
|
data: {
|
|
id: 5,
|
|
collection: 'posts',
|
|
item: '1',
|
|
comment: 'Awesome post!',
|
|
},
|
|
});
|
|
|
|
const sdk = new Directus(url);
|
|
const item = await sdk.activity.comments.create({
|
|
collection: 'posts',
|
|
item: '1',
|
|
comment: 'Awesome post!',
|
|
});
|
|
|
|
expect(item.id).toBe(5);
|
|
expect(item.comment).toBe('Awesome post!');
|
|
});
|
|
|
|
test(`updates comments`, async (url, nock) => {
|
|
nock()
|
|
.patch('/activity/comment/5', {
|
|
comment: 'Awesome content!',
|
|
})
|
|
.reply(202, {
|
|
data: {
|
|
id: 5,
|
|
collection: 'posts',
|
|
item: '1',
|
|
comment: 'Awesome content!',
|
|
},
|
|
});
|
|
|
|
const sdk = new Directus(url);
|
|
const item = await sdk.activity.comments.update(5, 'Awesome content!');
|
|
|
|
expect(item.comment).toBe('Awesome content!');
|
|
});
|
|
|
|
test(`deletes comments`, async (url, nock) => {
|
|
const scope = nock().delete('/activity/comment/5').reply(204);
|
|
|
|
const sdk = new Directus(url);
|
|
await sdk.activity.comments.delete(5);
|
|
|
|
expect(scope.pendingMocks().length).toBe(0);
|
|
});
|
|
});
|