Skip to content

Commit beb41fa

Browse files
committed
test(input, textarea): verify the inheritted watch attribute
1 parent 1c50bfb commit beb41fa

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

core/src/components/input/test/input.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,24 @@ describe('input: rendering', () => {
4444
const bottomContent = page.body.querySelector('ion-input .input-bottom');
4545
expect(bottomContent).toBe(null);
4646
});
47+
48+
it('should inherit watched attributes', async () => {
49+
const page = await newSpecPage({
50+
components: [Input],
51+
html: '<ion-input label="Input" dir="ltr"></ion-input>',
52+
});
53+
54+
const inputEl = page.body.querySelector('ion-input')!;
55+
const nativeEl = inputEl.querySelector('input')!;
56+
57+
expect(nativeEl.getAttribute('dir')).toBe('ltr');
58+
59+
inputEl.setAttribute('dir', 'rtl');
60+
61+
await page.waitForChanges();
62+
63+
expect(nativeEl.getAttribute('dir')).toBe('rtl');
64+
});
4765
});
4866

4967
/**

core/src/components/textarea/test/textarea.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@ it('should inherit attributes', async () => {
1414
expect(nativeEl.getAttribute('data-form-type')).toBe('password');
1515
});
1616

17+
it('should inherit watched attributes', async () => {
18+
const page = await newSpecPage({
19+
components: [Textarea],
20+
html: '<ion-textarea dir="ltr"></ion-textarea>',
21+
});
22+
23+
const textareaEl = page.body.querySelector('ion-input')!;
24+
const nativeEl = textareaEl.querySelector('textarea')!;
25+
26+
expect(nativeEl.getAttribute('dir')).toBe('ltr');
27+
28+
textareaEl.setAttribute('dir', 'rtl');
29+
30+
await page.waitForChanges();
31+
32+
expect(nativeEl.getAttribute('dir')).toBe('rtl');
33+
});
34+
1735
/**
1836
* Textarea uses emulated slots, so the internal
1937
* behavior will not exactly match IonSelect's slots.

0 commit comments

Comments
 (0)