]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/plugins/translations.ts
Implement getServerListeningConfig plugin helper
[github/Chocobozzz/PeerTube.git] / server / tests / plugins / translations.ts
1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3 import { expect } from 'chai'
4 import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers } from '@shared/server-commands'
5
6 describe('Test plugin translations', function () {
7 let server: PeerTubeServer
8 let command: PluginsCommand
9
10 before(async function () {
11 this.timeout(30000)
12
13 server = await createSingleServer(1)
14 await setAccessTokensToServers([ server ])
15
16 command = server.plugins
17
18 await command.install({ path: PluginsCommand.getPluginTestPath() })
19 await command.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') })
20 })
21
22 it('Should not have translations for locale pt', async function () {
23 const body = await command.getTranslations({ locale: 'pt' })
24
25 expect(body).to.deep.equal({})
26 })
27
28 it('Should have translations for locale fr', async function () {
29 const body = await command.getTranslations({ locale: 'fr-FR' })
30
31 expect(body).to.deep.equal({
32 'peertube-plugin-test': {
33 Hi: 'Coucou'
34 },
35 'peertube-plugin-test-filter-translations': {
36 'Hello world': 'Bonjour le monde'
37 }
38 })
39 })
40
41 it('Should have translations of locale it', async function () {
42 const body = await command.getTranslations({ locale: 'it-IT' })
43
44 expect(body).to.deep.equal({
45 'peertube-plugin-test-filter-translations': {
46 'Hello world': 'Ciao, mondo!'
47 }
48 })
49 })
50
51 it('Should remove the plugin and remove the locales', async function () {
52 await command.uninstall({ npmName: 'peertube-plugin-test-filter-translations' })
53
54 {
55 const body = await command.getTranslations({ locale: 'fr-FR' })
56
57 expect(body).to.deep.equal({
58 'peertube-plugin-test': {
59 Hi: 'Coucou'
60 }
61 })
62 }
63
64 {
65 const body = await command.getTranslations({ locale: 'it-IT' })
66
67 expect(body).to.deep.equal({})
68 }
69 })
70
71 after(async function () {
72 await cleanupTests([ server ])
73 })
74 })