import { describe, expect, it } from '@jest/globals'; import { render, screen as rtlScreen } from '@testing-library/react'; import { type FC, useContext } from 'react'; import { getThemeFromSystem } from '../../helpers'; import { ThemeContext, ThemeProvider } from './theme-provider'; const bodyPrefix = 'Current theme is:'; const ComponentTest: FC = () => { const { theme } = useContext(ThemeContext); return (
{bodyPrefix} {theme}
); }; describe('ThemeProvider', () => { it('uses the default value when the provider is not used', () => { const defaultValue = 'system'; render(); expect(rtlScreen.getByText(new RegExp(bodyPrefix))).toHaveTextContent( `${bodyPrefix} ${defaultValue}` ); }); it('provides the given value to its children and set a matching attribute', () => { const attribute = 'iure'; const theme = 'dark'; const { baseElement } = render( ); expect(rtlScreen.getByText(new RegExp(bodyPrefix))).toHaveTextContent( `${bodyPrefix} ${theme}` ); expect(baseElement.parentElement?.getAttribute(`data-${attribute}`)).toBe( theme ); expect(baseElement.parentElement).toHaveStyle(`color-scheme: ${theme};`); }); it('can resolve the preferred theme from user system settings', () => { const attribute = 'qui'; const defaultTheme = 'system'; const resolvedTheme = getThemeFromSystem(); const { baseElement } = render( ); expect(rtlScreen.getByText(new RegExp(bodyPrefix))).toHaveTextContent( `${bodyPrefix} ${defaultTheme}` ); expect(baseElement.parentElement?.getAttribute(`data-${attribute}`)).toBe( resolvedTheme ); expect(baseElement.parentElement).toHaveStyle( `color-scheme: ${resolvedTheme};` ); }); }); prism/prism-typoscript.min.js'>
path: root/public/prism/prism-typoscript.min.js
blob: 2873c432b21617050d5a2a9ae24ec32fa2db085a (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
47
48
!(function (E) {
  var n =
    /\b(?:ACT|ACTIFSUB|CARRAY|CASE|CLEARGIF|COA|COA_INT|CONSTANTS|CONTENT|CUR|EDITPANEL|EFFECT|EXT|FILE|FLUIDTEMPLATE|FORM|FRAME|FRAMESET|GIFBUILDER|GMENU|GMENU_FOLDOUT|GMENU_LAYERS|GP|HMENU|HRULER|HTML|IENV|IFSUB|IMAGE|IMGMENU|IMGMENUITEM|IMGTEXT|IMG_RESOURCE|INCLUDE_TYPOSCRIPT|JSMENU|JSMENUITEM|LLL|LOAD_REGISTER|NO|PAGE|RECORDS|RESTORE_REGISTER|TEMPLATE|TEXT|TMENU|TMENUITEM|TMENU_LAYERS|USER|USER_INT|_GIFBUILDER|global|globalString|globalVar)\b/;
  (E.languages.typoscript = {
    comment: [
      { pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, lookbehind: !0 },
      {
        pattern: /(^|[^\\:= \t]|(?:^|[^= \t])[ \t]+)\/\/.*/,
        lookbehind: !0,
        greedy: !0,
      },
      { pattern: /(^|[^"'])#.*/, lookbehind: !0, greedy: !0 },
    ],
    function: [
      {
        pattern:
          /<INCLUDE_TYPOSCRIPT:\s*source\s*=\s*(?:"[^"\r\n]*"|'[^'\r\n]*')\s*>/,
        inside: {
          string: {
            pattern: /"[^"\r\n]*"|'[^'\r\n]*'/,
            inside: { keyword: n },
          },
          keyword: { pattern: /INCLUDE_TYPOSCRIPT/ },
        },
      },
      {
        pattern: /@import\s*(?:"[^"\r\n]*"|'[^'\r\n]*')/,
        inside: { string: /"[^"\r\n]*"|'[^'\r\n]*'/ },
      },
    ],
    string: {
      pattern: /^([^=]*=[< ]?)(?:(?!\]\n).)*/,
      lookbehind: !0,
      inside: {
        function: /\{\$.*\}/,
        keyword: n,
        number: /^\d+$/,
        punctuation: /[,|:]/,
      },
    },
    keyword: n,
    number: { pattern: /\b\d+\s*[.{=]/, inside: { operator: /[.{=]/ } },
    tag: { pattern: /\.?[-\w\\]+\.?/, inside: { punctuation: /\./ } },
    punctuation: /[{}[\];(),.:|]/,
    operator: /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
  }),
    (E.languages.tsconfig = E.languages.typoscript);
})(Prism);