Skip to content

Commit

Permalink
Merge branch 'main' into VIV-2236-filepicker-scrollbar
Browse files Browse the repository at this point in the history
  • Loading branch information
rachelbt authored Nov 27, 2024
2 parents 26db6cd + c7b869c commit ad5aa29
Show file tree
Hide file tree
Showing 6 changed files with 337 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .whitesource
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"settingsInheritedFrom": "Vonage/whitesource-config@main"
}
1 change: 1 addition & 0 deletions libs/components/src/lib/text-field/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,5 +223,6 @@ The `helper-text` slot allows you to use rich content as the text-field's helper
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `checkValidity` | Returns `true` if the element's `value` passes validity checks; otherwise, returns `false` and fires an `invalid` event at the element. |
| `reportValidity` | Returns `true` if the element's `value` passes validity checks; otherwise, returns `false`, fires an `invalid` event at the element, and (if the event isn't canceled) reports the problem to the user. |
| `select` | Selects all the text in the text field |

</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { FormAssociated, FoundationElement } from '@microsoft/fast-foundation';

class _TextField extends FoundationElement {}
// eslint-disable-next-line @typescript-eslint/naming-convention
interface _TextField extends FormAssociated {}

export class FormAssociatedTextField extends FormAssociated(_TextField) {
proxy = document.createElement('input');
}
27 changes: 27 additions & 0 deletions libs/components/src/lib/text-field/text-field.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,15 @@ describe('vwc-text-field', () => {
await elementUpdated(element);
expect(getInput()?.hasAttribute('autofocus')).toEqual(true);
});

it('should focus the input element when connected', async () => {
element = (await fixture(
`<${COMPONENT_TAG_NAME} autofocus></${COMPONENT_TAG_NAME}>`
)) as TextField;
await elementUpdated(element);

expect(document.activeElement).toEqual(getInput());
});
});

describe('inputmode', function () {
Expand Down Expand Up @@ -238,6 +247,14 @@ describe('vwc-text-field', () => {
});
});

describe('spellcheck', function () {
it('should set spellcheck attribute on the input', async function () {
element.spellcheck = true;
await elementUpdated(element);
expect(getInput()?.hasAttribute('spellcheck')).toBe(true);
});
});

describe('maxlength', function () {
const value = '8';
const propertyName = 'maxlength';
Expand Down Expand Up @@ -634,6 +651,16 @@ describe('vwc-text-field', () => {
});
});

describe('select method', function () {
it('should call select on the input', async function () {
getInput().select = jest.fn();

element.select();

expect(getInput().select).toHaveBeenCalled();
});
});

describe('accessible helper text', function () {
function getAccessibleDescription() {
const describedBy = element
Expand Down
Loading

0 comments on commit ad5aa29

Please sign in to comment.