-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test: add test scripts * ci: update github workflows * ci: format gh-pages.yml * ci: format gh-pages.yml * ci: update gh-pages.yml * docs: update README.md * ci: update gh-pages.yml
- Loading branch information
Showing
17 changed files
with
2,256 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-20.04 | ||
permissions: | ||
contents: write | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 'lts/*' | ||
|
||
- name: Install | ||
run: npm install | ||
|
||
- name: Build | ||
run: npm run build:docs | ||
|
||
- name: Deploy | ||
uses: peaceiris/actions-gh-pages@v3 | ||
if: github.ref == 'refs/heads/master' | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./docs/assets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
|
||
name: Node.js CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
jobs: | ||
test: | ||
name: 'Test' | ||
runs-on: ubuntu-latest | ||
container: node:16 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: npm install | ||
- run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# see https://help.github.com/cn/actions/language-and-framework-guides/publishing-nodejs-packages | ||
|
||
name: Node.js Package | ||
|
||
on: | ||
push: | ||
tags: ['*'] | ||
|
||
jobs: | ||
publish: | ||
name: 'Publish' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
# Setup .npmrc file to publish to npm | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: '12.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Build | ||
run: npm run build | ||
|
||
- name: Npm Publish | ||
run: npm publish dist | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react'; | ||
import { render, act } from '@testing-library/react'; | ||
import CodeEditor from '../src/CodeEditor'; | ||
|
||
it('renders without crashing', async () => { | ||
await act(async () => { | ||
render(<CodeEditor />); | ||
}); | ||
}); | ||
|
||
it('editor should be initialized', async () => { | ||
await act(async () => { | ||
const { container } = render( | ||
<CodeEditor | ||
onInitialized={() => { | ||
expect(container.querySelector('.rcv-editor-loader')).toBeFalsy(); | ||
}} | ||
/> | ||
); | ||
expect(container.querySelector('.rcv-editor-loader')).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
it('should be initialized code', async () => { | ||
await act(async () => { | ||
const { container } = render( | ||
<CodeEditor | ||
code={'const a = 1;'} | ||
onInitialized={() => { | ||
expect(container.querySelector('textarea').value).toBe('const a = 1;'); | ||
expect(container.querySelector('.CodeMirror').textContent).toBe('const a = 1;'); | ||
}} | ||
/> | ||
); | ||
expect(container.querySelector('.rcv-editor-loader')).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
it('should call onChange callback', async () => { | ||
await act(async () => { | ||
const { container } = render( | ||
<CodeEditor | ||
code={'const a = 1;'} | ||
onChange={value => { | ||
expect(container.querySelector('textarea').value).toBe('const a = 1;'); | ||
expect(value).toBe('const a = 2;'); | ||
}} | ||
onInitialized={editor => { | ||
editor.setValue('const a = 2;'); | ||
}} | ||
/> | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { render } from '@testing-library/react'; | ||
import ErrorBoundary from '../src/ErrorBoundary'; | ||
|
||
it('renders error message', () => { | ||
const { getByText } = render(<ErrorBoundary hasError errorMessage="test message" />); | ||
|
||
expect(getByText('test message')).toBeTruthy(); | ||
}); | ||
|
||
it('render child elements', () => { | ||
const { getByText } = render(<ErrorBoundary>child</ErrorBoundary>); | ||
expect(getByText('child')).toBeTruthy(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { render } from '@testing-library/react'; | ||
import Preview from '../src/Preview'; | ||
|
||
it('renders without crashing', () => { | ||
const { container } = render(<Preview />); | ||
expect(container).toBeTruthy(); | ||
}); | ||
|
||
it('render a loader', () => { | ||
const { container } = render(<Preview />); | ||
expect(container.querySelector('.rcv-render-loader')).toBeTruthy(); | ||
}); | ||
|
||
it('render child elements', () => { | ||
const { getByText } = render( | ||
<Preview> | ||
<button>test</button> | ||
</Preview> | ||
); | ||
expect(getByText('test')).toBeTruthy(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* For a detailed explanation regarding each configuration property, visit: | ||
* https://jestjs.io/docs/configuration | ||
*/ | ||
|
||
module.exports = { | ||
collectCoverage: true, | ||
coverageDirectory: 'coverage', | ||
coverageProvider: 'v8', | ||
testEnvironment: 'jsdom', | ||
setupFilesAfterEnv: ['<rootDir>/setup-jest.js'] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.