2020-01-31 09:56:52 -06:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
2019-07-26 07:44:50 -05:00
|
|
|
|
|
|
|
import 'mocha'
|
2021-07-07 03:33:49 -05:00
|
|
|
import * as chai from 'chai'
|
|
|
|
import { PluginsCommand, setAccessTokensToServers } from '../../../shared/extra-utils'
|
2020-01-31 09:56:52 -06:00
|
|
|
import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers'
|
2019-07-26 07:44:50 -05:00
|
|
|
|
|
|
|
const expect = chai.expect
|
|
|
|
|
|
|
|
describe('Test plugin translations', function () {
|
|
|
|
let server: ServerInfo
|
2021-07-07 03:33:49 -05:00
|
|
|
let command: PluginsCommand
|
2019-07-26 07:44:50 -05:00
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
this.timeout(30000)
|
|
|
|
|
|
|
|
server = await flushAndRunServer(1)
|
|
|
|
await setAccessTokensToServers([ server ])
|
|
|
|
|
2021-07-16 02:04:35 -05:00
|
|
|
command = server.plugins
|
2019-07-26 07:44:50 -05:00
|
|
|
|
2021-07-07 03:33:49 -05:00
|
|
|
await command.install({ path: PluginsCommand.getPluginTestPath() })
|
|
|
|
await command.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') })
|
2019-07-26 07:44:50 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should not have translations for locale pt', async function () {
|
2021-07-07 03:33:49 -05:00
|
|
|
const body = await command.getTranslations({ locale: 'pt' })
|
2019-07-26 07:44:50 -05:00
|
|
|
|
2021-07-07 03:33:49 -05:00
|
|
|
expect(body).to.deep.equal({})
|
2019-07-26 07:44:50 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should have translations for locale fr', async function () {
|
2021-07-07 03:33:49 -05:00
|
|
|
const body = await command.getTranslations({ locale: 'fr-FR' })
|
2019-07-26 07:44:50 -05:00
|
|
|
|
2021-07-07 03:33:49 -05:00
|
|
|
expect(body).to.deep.equal({
|
2019-07-26 07:44:50 -05:00
|
|
|
'peertube-plugin-test': {
|
2020-01-31 09:56:52 -06:00
|
|
|
Hi: 'Coucou'
|
2019-07-26 07:44:50 -05:00
|
|
|
},
|
2021-06-17 09:02:38 -05:00
|
|
|
'peertube-plugin-test-filter-translations': {
|
2019-07-26 07:44:50 -05:00
|
|
|
'Hello world': 'Bonjour le monde'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should have translations of locale it', async function () {
|
2021-07-07 03:33:49 -05:00
|
|
|
const body = await command.getTranslations({ locale: 'it-IT' })
|
2019-07-26 07:44:50 -05:00
|
|
|
|
2021-07-07 03:33:49 -05:00
|
|
|
expect(body).to.deep.equal({
|
2021-06-17 09:02:38 -05:00
|
|
|
'peertube-plugin-test-filter-translations': {
|
2019-07-26 07:44:50 -05:00
|
|
|
'Hello world': 'Ciao, mondo!'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should remove the plugin and remove the locales', async function () {
|
2021-07-07 03:33:49 -05:00
|
|
|
await command.uninstall({ npmName: 'peertube-plugin-test-filter-translations' })
|
2019-07-26 07:44:50 -05:00
|
|
|
|
|
|
|
{
|
2021-07-07 03:33:49 -05:00
|
|
|
const body = await command.getTranslations({ locale: 'fr-FR' })
|
2019-07-26 07:44:50 -05:00
|
|
|
|
2021-07-07 03:33:49 -05:00
|
|
|
expect(body).to.deep.equal({
|
2019-07-26 07:44:50 -05:00
|
|
|
'peertube-plugin-test': {
|
2020-01-31 09:56:52 -06:00
|
|
|
Hi: 'Coucou'
|
2019-07-26 07:44:50 -05:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2021-07-07 03:33:49 -05:00
|
|
|
const body = await command.getTranslations({ locale: 'it-IT' })
|
2019-07-26 07:44:50 -05:00
|
|
|
|
2021-07-07 03:33:49 -05:00
|
|
|
expect(body).to.deep.equal({})
|
2019-07-26 07:44:50 -05:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
after(async function () {
|
|
|
|
await cleanupTests([ server ])
|
|
|
|
})
|
|
|
|
})
|