-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from tidbcloud/feat/unit-test
Feat/unit test
- Loading branch information
Showing
6 changed files
with
6,052 additions
and
3,815 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
presets: [ | ||
'@babel/preset-env', | ||
'@babel/preset-react', | ||
'@babel/preset-typescript' | ||
] | ||
} |
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,8 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
testEnvironment: 'jsdom', | ||
transform: { | ||
'^.+\\.(ts|tsx)?$': 'babel-jest', | ||
'^.+\\.(js|jsx)$': 'babel-jest' | ||
} | ||
} |
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,17 @@ | ||
import { createSQLEditorInstance } from '../editor-instance' | ||
|
||
function sum(a: number, b: number) { | ||
return a + b | ||
} | ||
|
||
test('adds 1 + 2 to equal 3', () => { | ||
expect(sum(1, 2)).toBe(3) | ||
}) | ||
|
||
test('create instance successfully', () => { | ||
const instance = createSQLEditorInstance({ | ||
editorId: '111', | ||
doc: '222' | ||
}) | ||
expect(instance.editorId).toBe('111') | ||
}) |
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,14 @@ | ||
import { render, screen } from '@testing-library/react' | ||
// import SQLEditor from '../sql-editor' | ||
import '@testing-library/jest-dom' | ||
// @ts-ignore | ||
import React from 'react' | ||
|
||
const Example = () => { | ||
return <input></input> | ||
} | ||
|
||
test('test with react-testing-library', () => { | ||
render(<Example />) | ||
expect(screen.getByRole('textbox')).toBeEnabled() | ||
}) |
Oops, something went wrong.