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