diff options
-rw-r--r-- | server/tests/api/check-params/actors.ts | 37 | ||||
-rw-r--r-- | shared/extra-utils/actors/actors.ts | 18 | ||||
-rw-r--r-- | shared/extra-utils/index.ts | 1 |
3 files changed, 56 insertions, 0 deletions
diff --git a/server/tests/api/check-params/actors.ts b/server/tests/api/check-params/actors.ts new file mode 100644 index 000000000..3a03edc39 --- /dev/null +++ b/server/tests/api/check-params/actors.ts | |||
@@ -0,0 +1,37 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import 'mocha' | ||
4 | |||
5 | import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../../shared/extra-utils' | ||
6 | import { getActor } from '../../../../shared/extra-utils/actors/actors' | ||
7 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
8 | |||
9 | describe('Test actors API validators', function () { | ||
10 | let server: ServerInfo | ||
11 | |||
12 | // --------------------------------------------------------------- | ||
13 | |||
14 | before(async function () { | ||
15 | this.timeout(30000) | ||
16 | |||
17 | server = await flushAndRunServer(1) | ||
18 | }) | ||
19 | |||
20 | describe('When getting an actor', function () { | ||
21 | it('Should return 404 with a non existing actorName', async function () { | ||
22 | await getActor(server.url, 'arfaze', HttpStatusCode.NOT_FOUND_404) | ||
23 | }) | ||
24 | |||
25 | it('Should return 200 with an existing accountName', async function () { | ||
26 | await getActor(server.url, 'root', HttpStatusCode.OK_200) | ||
27 | }) | ||
28 | |||
29 | it('Should return 200 with an existing channelName', async function () { | ||
30 | await getActor(server.url, 'root_channel', HttpStatusCode.OK_200) | ||
31 | }) | ||
32 | }) | ||
33 | |||
34 | after(async function () { | ||
35 | await cleanupTests([ server ]) | ||
36 | }) | ||
37 | }) | ||
diff --git a/shared/extra-utils/actors/actors.ts b/shared/extra-utils/actors/actors.ts new file mode 100644 index 000000000..4a4aba775 --- /dev/null +++ b/shared/extra-utils/actors/actors.ts | |||
@@ -0,0 +1,18 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import { makeGetRequest } from '../requests/requests' | ||
4 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
5 | |||
6 | function getActor (url: string, actorName: string, statusCodeExpected = HttpStatusCode.OK_200) { | ||
7 | const path = '/api/v1/actors/' + actorName | ||
8 | |||
9 | return makeGetRequest({ | ||
10 | url, | ||
11 | path, | ||
12 | statusCodeExpected | ||
13 | }) | ||
14 | } | ||
15 | |||
16 | export { | ||
17 | getActor | ||
18 | } | ||
diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts index 898a92d43..5c520d0c2 100644 --- a/shared/extra-utils/index.ts +++ b/shared/extra-utils/index.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | export * from './actors/actors' | ||
1 | export * from './bulk/bulk' | 2 | export * from './bulk/bulk' |
2 | export * from './cli/cli' | 3 | export * from './cli/cli' |
3 | export * from './feeds/feeds' | 4 | export * from './feeds/feeds' |