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