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