-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
82 additions
and
10 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 @@ | ||
module.exports = {}; |
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,16 @@ | ||
module.exports = { | ||
"roots": [ | ||
"<rootDir>/src" | ||
], | ||
"testMatch": [ | ||
"**/__tests__/**/*.+(ts|tsx|js)", | ||
"**/?(*.)+(spec|test).+(ts|tsx|js)" | ||
], | ||
"transform": { | ||
"^.+\\.(ts|tsx)$": "ts-jest" | ||
}, | ||
"moduleNameMapper": { | ||
'\\.(css|less)$': '<rootDir>/__mocks__/styleMock.js', | ||
}, | ||
"testEnvironment": "jsdom" | ||
} |
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 @@ | ||
import * as React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { CreateButton } from '../Button'; | ||
import '@testing-library/jest-dom' | ||
|
||
describe('CreateButton', () => { | ||
it('should have "Create Snippet" as button label', () => { | ||
render(<CreateButton applicationData={null} data={null} name={null} />); | ||
const buttonElement = screen.getByRole('button', { name: /Create Snippet/i }); | ||
expect(buttonElement).toBeInTheDocument(); | ||
}); | ||
}); |
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,35 @@ | ||
import * as React from 'react'; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import { DataTextInput } from '../TextInput'; | ||
import '@testing-library/jest-dom'; | ||
|
||
describe('DataTextInput', () => { | ||
test('renders input and textarea elements', () => { | ||
render(<DataTextInput applicationData={null} />); | ||
|
||
const nameInput = screen.getByPlaceholderText('Type the name of your snippet...') as HTMLInputElement; | ||
const dataTextarea = screen.getByPlaceholderText('Add your code/text content into this box') as HTMLTextAreaElement; | ||
|
||
expect(nameInput).toBeInTheDocument(); | ||
expect(dataTextarea).toBeInTheDocument(); | ||
}); | ||
|
||
test('updates the state when input and textarea values change', () => { | ||
render(<DataTextInput applicationData={null} />); | ||
|
||
const nameInput = screen.getByPlaceholderText('Type the name of your snippet...') as HTMLInputElement; | ||
const dataTextarea = screen.getByPlaceholderText('Add your code/text content into this box') as HTMLTextAreaElement; | ||
|
||
// Simulate user input and check if the state is updated accordingly | ||
expect(nameInput.value).toEqual(''); | ||
fireEvent.change(nameInput, { target: { value: 'Snippet name' } }); | ||
expect(nameInput.value).toEqual('Snippet name'); | ||
|
||
expect(dataTextarea.value).toEqual(''); | ||
fireEvent.change(dataTextarea, { target: { value: 'Snippet code' } }); | ||
expect(dataTextarea.value).toEqual('Snippet code'); | ||
}); | ||
}); | ||
|
||
|
||
|
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 |
---|---|---|
@@ -1,16 +1,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2020", | ||
"target": "es2022", | ||
"module": "CommonJS", | ||
"allowJs": true, | ||
"checkJs": true, | ||
"allowJs": true, | ||
"checkJs": true, | ||
"types": ["@testing-library/jest-dom"], | ||
"forceConsistentCasingInFileNames": true, | ||
|
||
"outDir": "./dist", | ||
/* Type Checking */ | ||
"strict": false, | ||
"skipLibCheck": true, | ||
/* Skip type checking all .d.ts files. */ | ||
"jsx": "react" | ||
}, | ||
"exclude": ["node_modules"] | ||
} | ||
"exclude": ["node_modules","jest.config.js", "**/__mocks__/*"] | ||
} |