-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Forms): add innerRef to Field.String for React.ref support (#2679)
- Loading branch information
1 parent
4eda388
commit 930b89d
Showing
5 changed files
with
94 additions
and
25 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
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
50 changes: 50 additions & 0 deletions
50
packages/dnb-eufemia/src/extensions/forms/Field/__tests__/OrganizationNumbe.test.tsx
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,50 @@ | ||
import React from 'react' | ||
import { render } from '@testing-library/react' | ||
import userEvent from '@testing-library/user-event' | ||
import OrganizationNumber from '../OrganizationNumber' | ||
|
||
describe('Field.OrganizationNumber', () => { | ||
it('should have Norwegian mask', async () => { | ||
render(<OrganizationNumber />) | ||
|
||
const element = document.querySelector('input') | ||
await userEvent.type(element, '123456789') | ||
expect(element.value).toBe('123 456 789') | ||
}) | ||
|
||
it('should have medium width', () => { | ||
render(<OrganizationNumber />) | ||
|
||
const element = document.querySelector( | ||
'.dnb-forms-field-block__contents' | ||
) | ||
expect(element.className).toContain( | ||
'dnb-forms-field-block__contents--width-medium' | ||
) | ||
}) | ||
|
||
it('should have disabled autocomplete', () => { | ||
render(<OrganizationNumber />) | ||
|
||
const element = document.querySelector('input') | ||
expect(element.autocomplete).toBe('off') | ||
}) | ||
|
||
it('should link for and label', () => { | ||
render(<OrganizationNumber />) | ||
|
||
const labelElement = document.querySelector('label') | ||
const inputElement = document.querySelector('input') | ||
|
||
expect(inputElement.getAttribute('id')).toBe( | ||
labelElement.getAttribute('for') | ||
) | ||
}) | ||
|
||
it('should have default label', () => { | ||
render(<OrganizationNumber />) | ||
|
||
const element = document.querySelector('label') | ||
expect(element.textContent).toBe('Organisasjonsnummer') | ||
}) | ||
}) |
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