diff --git a/.eslintignore b/.eslintignore index 8f042b0a..53d9e838 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,5 @@ node_modules/ coverage/ dist/ +public/index* __tests__/__fixtures__/**/sample.* diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d906525..0c95cc2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,6 @@ on: [push] jobs: build: - runs-on: ubuntu-latest strategy: @@ -12,34 +11,28 @@ jobs: node: - 18 - 20 - react: [16, 17] + react: [16, 17, 18] name: build (${{ matrix.node }} w/ React ${{ matrix.react }} steps: - - uses: actions/checkout@v4 - - - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node }} + - uses: actions/checkout@v4 - - name: Install dependencies - run: npm ci + - name: Use Node.js ${{ matrix.node }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} - - name: Install React v${{ matrix.react }} - run: npm i react@${{ matrix.react }} react-dom@${{ matrix.react }} + - name: Install dependencies + run: npm ci - - name: Install React 16 Enzyme adapter - if: matrix.react == '16' - run: | - npm remove @wojtekmaj/enzyme-adapter-react-17 - npm install enzyme-adapter-react-16 + - name: Install Compatible @testing-library/react + if: matrix.react == '16' || matrix.react == '17' + run: | + npm install @testing-library/react@12 - - name: Run tests on React 16 - if: matrix.react == '16' - run: REACT_VERSION=16 npm test + - name: Install React v${{ matrix.react }} + run: npm i react@${{ matrix.react }} react-dom@${{ matrix.react }} - - name: Run tests on React 17 - if: matrix.react == '17' - run: npm test + - name: Run tests on React ${{ matrix.react }} + run: REACT_VERSION=${{ matrix.react }} npm test diff --git a/__tests__/__snapshots__/codeMirror.test.js.snap b/__tests__/__snapshots__/codeMirror.test.js.snap index e1e2e49a..aae9551f 100644 --- a/__tests__/__snapshots__/codeMirror.test.js.snap +++ b/__tests__/__snapshots__/codeMirror.test.js.snap @@ -1,82 +1,82 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Supported languages ASP.NET should syntax highlight an example 1`] = ` -"
{{firstname}} {{lastname}}
'; - expect(shallow(syntaxHighlighter(code, 'handlebars')).html()).toContain('cm-bracket'); + const { container } = render(syntaxHighlighter(code, 'handlebars')); + + expect(container.querySelector('.cm-bracket')).toBeVisible(); }); } else if (instructions.mode.primary === 'php') { it('should highlight if missing an opening ` { - expect(shallow(syntaxHighlighter('echo "Hello World";', 'php')).html()).toContain('cm-keyword'); + const code = 'echo "Hello World";'; + const { container } = render(syntaxHighlighter(code, 'php')); + + expect(container.querySelector('.cm-keyword')).toBeVisible(); }); } }); }); describe('highlight mode', () => { - let node; const code = `curl --request POST --url <{syntaxHighlighter(exampleJson, 'json', { foldGutter: true, readOnly: true, dark: false })}-
++ ++ {syntaxHighlighter(exampleCode, 'curl', { + dark: true, + highlightMode: true, + tokenizeVariables: true, + ranges: [ + [ + { ch: 0, line: 0 }, + { ch: 0, line: 1 }, + ], + [ + { ch: 0, line: 4 }, + { ch: 0, line: 5 }, + ], + ], + })} + +
++ ++ {syntaxHighlighter(exampleCode, 'curl', { + dark: false, + highlightMode: true, + tokenizeVariables: true, + ranges: [ + [ + { ch: 0, line: 0 }, + { ch: 0, line: 1 }, + ], + [ + { ch: 0, line: 4 }, + { ch: 0, line: 5 }, + ], + ], + })} + +
+ {syntaxHighlighter(exampleMarkdown, 'md', { scrollbarStyle: 'overlay', editable: true, dark: true })} ++ +
+ {syntaxHighlighter(exampleMarkdown, 'md', { scrollbarStyle: 'overlay', editable: true, dark: false })} ++ +
+ {syntaxHighlighter(exampleJson, 'json', { foldGutter: true, readOnly: true, dark: true })} ++ +
+ {syntaxHighlighter(exampleJson, 'json', { foldGutter: true, readOnly: true, dark: false })} ++