From d897210c2db1ca2acc1e7b28a13127647ab2222c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 8 Jul 2021 10:23:21 +0200 Subject: Introduce services command --- shared/extra-utils/videos/index.ts | 2 +- shared/extra-utils/videos/services-command.ts | 28 +++++++++++++++++++++++++++ shared/extra-utils/videos/services.ts | 24 ----------------------- 3 files changed, 29 insertions(+), 25 deletions(-) create mode 100644 shared/extra-utils/videos/services-command.ts delete mode 100644 shared/extra-utils/videos/services.ts (limited to 'shared/extra-utils/videos') diff --git a/shared/extra-utils/videos/index.ts b/shared/extra-utils/videos/index.ts index c9c884285..fe5dc6655 100644 --- a/shared/extra-utils/videos/index.ts +++ b/shared/extra-utils/videos/index.ts @@ -1,6 +1,6 @@ export * from './live-command' export * from './live' -export * from './services' +export * from './services-command' export * from './video-blacklist' export * from './video-captions' export * from './video-change-ownership' diff --git a/shared/extra-utils/videos/services-command.ts b/shared/extra-utils/videos/services-command.ts new file mode 100644 index 000000000..3b618ef66 --- /dev/null +++ b/shared/extra-utils/videos/services-command.ts @@ -0,0 +1,28 @@ +import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' +import { AbstractCommand, OverrideCommandOptions } from '../shared' + +export class ServicesCommand extends AbstractCommand { + + getOEmbed (options: OverrideCommandOptions & { + oembedUrl: string + format?: string + maxHeight?: number + maxWidth?: number + }) { + const path = '/services/oembed' + const query = { + url: options.oembedUrl, + format: options.format, + maxheight: options.maxHeight, + maxwidth: options.maxWidth + } + + return this.getRequest({ + ...options, + + path, + query, + defaultExpectedStatus: HttpStatusCode.OK_200 + }) + } +} diff --git a/shared/extra-utils/videos/services.ts b/shared/extra-utils/videos/services.ts deleted file mode 100644 index e13a788bd..000000000 --- a/shared/extra-utils/videos/services.ts +++ /dev/null @@ -1,24 +0,0 @@ -import * as request from 'supertest' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' - -function getOEmbed (url: string, oembedUrl: string, format?: string, maxHeight?: number, maxWidth?: number) { - const path = '/services/oembed' - const query = { - url: oembedUrl, - format, - maxheight: maxHeight, - maxwidth: maxWidth - } - - return request(url) - .get(path) - .query(query) - .set('Accept', 'application/json') - .expect(HttpStatusCode.OK_200) -} - -// --------------------------------------------------------------------------- - -export { - getOEmbed -} -- cgit v1.2.3