Welcome to mirror list, hosted at ThFree Co, Russian Federation.

to_match_interpolated_text_spec.js « matchers « __helpers__ « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f6fd00011fe3945b6bed2ac76b61f5ad96381cc2 (plain)
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
describe('custom matcher toMatchInterpolatedText', () => {
  describe('malformed input', () => {
    it.each([null, 1, Symbol, Array, Object])(
      'fails graciously if the expected value is %s',
      (expected) => {
        expect(expected).not.toMatchInterpolatedText('null');
      },
    );
  });
  describe('malformed matcher', () => {
    it.each([null, 1, Symbol, Array, Object])(
      'fails graciously if the matcher is %s',
      (matcher) => {
        expect('null').not.toMatchInterpolatedText(matcher);
      },
    );
  });

  describe('positive assertion', () => {
    it.each`
      htmlString         | templateString
      ${'foo'}           | ${'foo'}
      ${'foo'}           | ${'foo%{foo}'}
      ${'foo  '}         | ${'foo'}
      ${'foo  '}         | ${'foo%{foo}'}
      ${'foo   . '}      | ${'foo%{foo}.'}
      ${'foo   bar . '}  | ${'foo%{foo} bar.'}
      ${'foo\n\nbar . '} | ${'foo%{foo} bar.'}
      ${'foo bar . .'}   | ${'foo%{fooStart} bar.%{fooEnd}.'}
    `('$htmlString equals $templateString', ({ htmlString, templateString }) => {
      expect(htmlString).toMatchInterpolatedText(templateString);
    });
  });

  describe('negative assertion', () => {
    it.each`
      htmlString  | templateString
      ${'foo'}    | ${'bar'}
      ${'foo'}    | ${'bar%{foo}'}
      ${'foo'}    | ${'@{lol}foo%{foo}'}
      ${' fo o '} | ${'foo'}
    `('$htmlString does not equal $templateString', ({ htmlString, templateString }) => {
      expect(htmlString).not.toMatchInterpolatedText(templateString);
    });
  });
});