Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Klynger committed May 11, 2020
1 parent 83e3649 commit 6f8f325
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 39 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed
- Test errors.

### Securytiy
### Security
- Bump dependencies versions.

## [0.3.4] - 2020-04-15
Expand Down
8 changes: 0 additions & 8 deletions react/.eslintrc

This file was deleted.

56 changes: 29 additions & 27 deletions react/__tests__/Form.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,36 @@ import FormInputCheckbox from '../FormInputCheckbox'
import FormText from '../FormInputText'
import FormFieldGroup from '../FormFieldGroup'

test('should render full schema', () => {
const { getAllByText } = render(<Form entity="asdf" schema="asdf" />)
describe('Form', () => {
it('should render full schema', () => {
const { getAllByText } = render(<Form entity="asdf" schema="asdf" />)

expect(getAllByText('First Name')[0]).toBeDefined()
expect(getAllByText('Last Name')[0]).toBeDefined()
expect(getAllByText('Age')[0]).toBeDefined()
expect(getAllByText('Your height in meters')[0]).toBeDefined()
expect(getAllByText('Email address')[0]).toBeDefined()
expect(getAllByText('Street Type')[0]).toBeDefined()
expect(getAllByText('Address')[0]).toBeDefined()
expect(getAllByText('Street Number')[0]).toBeDefined()
expect(getAllByText('Do you agree with the terms?')[0]).toBeDefined()
})
expect(getAllByText('First Name')[0]).toBeDefined()
expect(getAllByText('Last Name')[0]).toBeDefined()
expect(getAllByText('Age')[0]).toBeDefined()
expect(getAllByText('Your height in meters')[0]).toBeDefined()
expect(getAllByText('Email address')[0]).toBeDefined()
expect(getAllByText('Street Type')[0]).toBeDefined()
expect(getAllByText('Address')[0]).toBeDefined()
expect(getAllByText('Street Number')[0]).toBeDefined()
expect(getAllByText('Do you agree with the terms?')[0]).toBeDefined()
})

test('should render partial schema', () => {
const { getAllByText } = render(
<Form entity="asdf" schema="asdf">
<FormText pointer="#/properties/firstName" />
<FormText pointer="#/properties/lastName" />
<FormFieldGroup pointer="#/properties/address" />
<FormInputCheckbox pointer="#/properties/agreement" />
</Form>
)
it('should render partial schema', () => {
const { getAllByText } = render(
<Form entity="asdf" schema="asdf">
<FormText pointer="#/properties/firstName" />
<FormText pointer="#/properties/lastName" />
<FormFieldGroup pointer="#/properties/address" />
<FormInputCheckbox pointer="#/properties/agreement" />
</Form>
)

expect(getAllByText('First Name')[0]).toBeDefined()
expect(getAllByText('Last Name')[0]).toBeDefined()
expect(getAllByText('Street Type')[0]).toBeDefined()
expect(getAllByText('Address')[0]).toBeDefined()
expect(getAllByText('Street Number')[0]).toBeDefined()
expect(getAllByText('Do you agree with the terms?')[0]).toBeDefined()
expect(getAllByText('First Name')[0]).toBeDefined()
expect(getAllByText('Last Name')[0]).toBeDefined()
expect(getAllByText('Street Type')[0]).toBeDefined()
expect(getAllByText('Address')[0]).toBeDefined()
expect(getAllByText('Street Number')[0]).toBeDefined()
expect(getAllByText('Do you agree with the terms?')[0]).toBeDefined()
})
})
4 changes: 2 additions & 2 deletions react/components/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const Checkbox: FC<{
{...(checked ? { checked: true } : { checked: false })}
onChange={() => {
const pointer = checkboxObject.pointer

console.log('styleguide checkbox - chamou boy')
checkboxObject.formContext.setValue(pointer, !checked)
}}
checked={Boolean(checked)}
Expand All @@ -55,7 +55,7 @@ export const Checkbox: FC<{
{...(checked ? { checked: true } : { checked: false })}
onChange={() => {
const pointer = checkboxObject.pointer

console.log('styleguide checkbox - chamou boy')
checkboxObject.formContext.setValue(pointer, !checked)
}}
checked={Boolean(checked)}
Expand Down
10 changes: 9 additions & 1 deletion react/setupTest.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
require('mutationobserver-shim')

window.matchMedia = () => {}
window.matchMedia =
window.matchMedia ||
function() {
return {
matches: false,
addListener: function() {},
removeListener: function() {},
}
}

0 comments on commit 6f8f325

Please sign in to comment.