]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
d75db01f C |
2 | |
3 | import * as chai from 'chai' | |
4 | import 'mocha' | |
a1587156 | 5 | import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' |
d75db01f | 6 | import { |
d75db01f | 7 | getPluginTestPath, |
a1587156 | 8 | getPluginTranslations, |
d75db01f | 9 | installPlugin, |
d75db01f | 10 | setAccessTokensToServers, |
a1587156 | 11 | uninstallPlugin |
d75db01f | 12 | } from '../../../shared/extra-utils' |
d75db01f C |
13 | |
14 | const expect = chai.expect | |
15 | ||
16 | describe('Test plugin translations', function () { | |
17 | let server: ServerInfo | |
18 | ||
19 | before(async function () { | |
20 | this.timeout(30000) | |
21 | ||
22 | server = await flushAndRunServer(1) | |
23 | await setAccessTokensToServers([ server ]) | |
24 | ||
25 | await installPlugin({ | |
26 | url: server.url, | |
27 | accessToken: server.accessToken, | |
28 | path: getPluginTestPath() | |
29 | }) | |
30 | ||
31 | await installPlugin({ | |
32 | url: server.url, | |
33 | accessToken: server.accessToken, | |
34 | path: getPluginTestPath('-two') | |
35 | }) | |
36 | }) | |
37 | ||
38 | it('Should not have translations for locale pt', async function () { | |
39 | const res = await getPluginTranslations({ url: server.url, locale: 'pt' }) | |
40 | ||
41 | expect(res.body).to.deep.equal({}) | |
42 | }) | |
43 | ||
44 | it('Should have translations for locale fr', async function () { | |
45 | const res = await getPluginTranslations({ url: server.url, locale: 'fr-FR' }) | |
46 | ||
47 | expect(res.body).to.deep.equal({ | |
48 | 'peertube-plugin-test': { | |
a1587156 | 49 | Hi: 'Coucou' |
d75db01f C |
50 | }, |
51 | 'peertube-plugin-test-two': { | |
52 | 'Hello world': 'Bonjour le monde' | |
53 | } | |
54 | }) | |
55 | }) | |
56 | ||
57 | it('Should have translations of locale it', async function () { | |
58 | const res = await getPluginTranslations({ url: server.url, locale: 'it-IT' }) | |
59 | ||
60 | expect(res.body).to.deep.equal({ | |
61 | 'peertube-plugin-test-two': { | |
62 | 'Hello world': 'Ciao, mondo!' | |
63 | } | |
64 | }) | |
65 | }) | |
66 | ||
67 | it('Should remove the plugin and remove the locales', async function () { | |
68 | await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-two' }) | |
69 | ||
70 | { | |
71 | const res = await getPluginTranslations({ url: server.url, locale: 'fr-FR' }) | |
72 | ||
73 | expect(res.body).to.deep.equal({ | |
74 | 'peertube-plugin-test': { | |
a1587156 | 75 | Hi: 'Coucou' |
d75db01f C |
76 | } |
77 | }) | |
78 | } | |
79 | ||
80 | { | |
81 | const res = await getPluginTranslations({ url: server.url, locale: 'it-IT' }) | |
82 | ||
83 | expect(res.body).to.deep.equal({}) | |
84 | } | |
85 | }) | |
86 | ||
87 | after(async function () { | |
88 | await cleanupTests([ server ]) | |
89 | }) | |
90 | }) |