File: i18next.defaults.spec.js

package info (click to toggle)
node-i18next 19.8.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,416 kB
  • sloc: javascript: 9,893; makefile: 2
file content (85 lines) | stat: -rw-r--r-- 2,726 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import * as defaultFc from '../src/defaults';
const defaults = defaultFc.get();

describe('defaults', () => {
  it('it should have default shortcut', () => {
    expect(defaults.overloadTranslationOptionHandler(['key', 'my default value'])).to.eql({
      defaultValue: 'my default value',
    });
  });

  it('defaultValue as option', () => {
    expect(
      defaults.overloadTranslationOptionHandler(['key', { defaultValue: 'option default value' }]),
    ).to.eql({ defaultValue: 'option default value' });
  });

  it('description', () => {
    expect(
      defaults.overloadTranslationOptionHandler(['key', 'my default value', 'the description']),
    ).to.eql({ defaultValue: 'my default value', tDescription: 'the description' });
  });

  it('description with options defaultValue', () => {
    // Options overwrites params default value
    expect(
      defaults.overloadTranslationOptionHandler(['key', 'my default value', 'the description']),
    ).to.eql({ defaultValue: 'my default value', tDescription: 'the description' });
  });

  it('interpolation', () => {
    expect(
      defaults.overloadTranslationOptionHandler([
        'key',
        'my default value {{params}}',
        { params: 'the value' },
      ]),
    ).to.eql({ defaultValue: 'my default value {{params}}', params: 'the value' });
  });

  it('interpolation with options defaultValue', () => {
    // Options overwrites params default value
    expect(
      defaults.overloadTranslationOptionHandler([
        'key',
        'my default value {{params}}',
        { defaultValue: 'options default value', params: 'the value' },
      ]),
    ).to.eql({ defaultValue: 'options default value', params: 'the value' });
  });

  it('interpolation description', () => {
    expect(
      defaults.overloadTranslationOptionHandler([
        'key',
        'my default value {{params}}',
        'the description',
        { params: 'the value' },
      ]),
    ).to.eql({
      defaultValue: 'my default value {{params}}',
      params: 'the value',
      tDescription: 'the description',
    });
  });

  it('interpolation description with options defaultValue', () => {
    // Options overwrites params default value
    expect(
      defaults.overloadTranslationOptionHandler([
        'key',
        'my default value {{params}}',
        'the description',
        { defaultValue: 'options default value', params: 'the value' },
      ]),
    ).to.eql({
      defaultValue: 'options default value',
      params: 'the value',
      tDescription: 'the description',
    });
  });

  it('it should have default format function', () => {
    expect(defaults.interpolation.format('my value', '###', 'de')).to.equal('my value');
  });
});