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

render_mermaid_spec.js « markdown « behaviors « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 51a345cab0eb64de5e67c51f88f52baf6ed70695 (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
import { initMermaid } from '~/behaviors/markdown/render_mermaid';
import * as ColorUtils from '~/lib/utils/color_utils';

describe('Render mermaid diagrams for Gitlab Flavoured Markdown', () => {
  it.each`
    darkMode | expectedTheme
    ${false} | ${'neutral'}
    ${true}  | ${'dark'}
  `('is $darkMode $expectedTheme', async ({ darkMode, expectedTheme }) => {
    jest.spyOn(ColorUtils, 'darkModeEnabled').mockImplementation(() => darkMode);

    const mermaid = {
      initialize: jest.fn(),
    };

    await initMermaid(mermaid);

    expect(mermaid.initialize).toHaveBeenCalledTimes(1);
    expect(mermaid.initialize).toHaveBeenCalledWith(
      expect.objectContaining({
        theme: expectedTheme,
      }),
    );
  });
});