translateSpec.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import {
  2. bootstrapDiagram,
  3. inject
  4. } from 'test/TestHelper';
  5. import translateModule from 'lib/i18n/translate';
  6. import customTranslateModule from './custom-translate';
  7. describe('i18n - translate', function() {
  8. describe('basics', function() {
  9. beforeEach(bootstrapDiagram({ modules: [ translateModule ] }));
  10. it('should provide translate helper', inject(function(translate) {
  11. expect(translate).to.be.a('function');
  12. }));
  13. it('should pass through', inject(function(translate) {
  14. expect(translate('FOO BAR')).to.eql('FOO BAR');
  15. }));
  16. it('should replace patterns', inject(function(translate) {
  17. expect(translate('FOO {bar}!', { bar: 'BAR' })).to.eql('FOO BAR!');
  18. }));
  19. it('should handle missing replacement', inject(function(translate) {
  20. expect(translate('FOO {bar}!')).to.eql('FOO {bar}!');
  21. }));
  22. it('should handle missing replacement', inject(function(translate) {
  23. expect(translate('FOO {bar}!', {})).to.eql('FOO {bar}!');
  24. }));
  25. });
  26. describe('custom translate / override', function() {
  27. beforeEach(bootstrapDiagram({ modules: [ translateModule, customTranslateModule ] }));
  28. it('should override translate', inject(function(translate) {
  29. expect(translate('Remove')).to.eql('Eliminar');
  30. }));
  31. });
  32. });