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