diff options
Diffstat (limited to 'types/tests')
-rw-r--r-- | types/tests/test.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/types/tests/test.ts b/types/tests/test.ts new file mode 100644 index 000000000..8c53320a1 --- /dev/null +++ b/types/tests/test.ts | |||
@@ -0,0 +1,32 @@ | |||
1 | import { RegisterServerOptions, Video } from '../dist' | ||
2 | import { RegisterClientOptions } from '../dist/client' | ||
3 | |||
4 | function register1 ({ registerHook }: RegisterServerOptions) { | ||
5 | registerHook({ | ||
6 | target: 'action:application.listening', | ||
7 | handler: () => console.log('hello') | ||
8 | }) | ||
9 | } | ||
10 | |||
11 | function register2 ({ registerHook, peertubeHelpers }: RegisterClientOptions) { | ||
12 | registerHook({ | ||
13 | target: 'action:admin-plugin-settings.init', | ||
14 | handler: ({ npmName }: { npmName: string }) => { | ||
15 | if ('peertube-plugin-transcription' !== npmName) { | ||
16 | return | ||
17 | } | ||
18 | }, | ||
19 | }) | ||
20 | |||
21 | registerHook({ | ||
22 | target: 'action:video-watch.video.loaded', | ||
23 | handler: ({ video }: { video: Video }) => { | ||
24 | fetch(`${peertubeHelpers.getBaseRouterRoute()}/videos/${video.uuid}/captions`, { | ||
25 | method: 'PUT', | ||
26 | headers: peertubeHelpers.getAuthHeader(), | ||
27 | }) | ||
28 | .then((res) => res.json()) | ||
29 | .then((data) => console.log('Hi %s.', data)) | ||
30 | }, | ||
31 | }) | ||
32 | } | ||