translations.ts 2.1 KB

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