mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 11:41:20 +08:00
test(input): merge render spec files (#27449)
Issue number: N/A --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> Input had two spec files for the same behavior. The only difference was the file type: `.ts` and `.tsx` ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Merged the spec test into one file ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> N/A
This commit is contained in:
@ -1,14 +1,46 @@
|
||||
import { newSpecPage } from '@stencil/core/testing';
|
||||
import { Input } from '../input';
|
||||
|
||||
it('should inherit attributes', async () => {
|
||||
const page = await newSpecPage({
|
||||
components: [Input],
|
||||
html: '<ion-input title="my title" tabindex="-1" data-form-type="password"></ion-input>',
|
||||
describe('input: rendering', () => {
|
||||
it('should inherit attributes', async () => {
|
||||
const page = await newSpecPage({
|
||||
components: [Input],
|
||||
html: '<ion-input title="my title" tabindex="-1" data-form-type="password"></ion-input>',
|
||||
});
|
||||
|
||||
const nativeEl = page.body.querySelector('ion-input input');
|
||||
expect(nativeEl.getAttribute('title')).toBe('my title');
|
||||
expect(nativeEl.getAttribute('tabindex')).toBe('-1');
|
||||
expect(nativeEl.getAttribute('data-form-type')).toBe('password');
|
||||
});
|
||||
|
||||
const nativeEl = page.body.querySelector('ion-input input');
|
||||
expect(nativeEl.getAttribute('title')).toBe('my title');
|
||||
expect(nativeEl.getAttribute('tabindex')).toBe('-1');
|
||||
expect(nativeEl.getAttribute('data-form-type')).toBe('password');
|
||||
it('should render bottom content when helper text is defined', async () => {
|
||||
const page = await newSpecPage({
|
||||
components: [Input],
|
||||
html: `<ion-input label="Input" helper-text="Helper Text"></ion-input>`,
|
||||
});
|
||||
|
||||
const bottomContent = page.body.querySelector('ion-input .input-bottom');
|
||||
expect(bottomContent).not.toBe(null);
|
||||
});
|
||||
|
||||
it('should render bottom content when helper text is undefined', async () => {
|
||||
const page = await newSpecPage({
|
||||
components: [Input],
|
||||
html: `<ion-input label="Input"></ion-input>`,
|
||||
});
|
||||
|
||||
const bottomContent = page.body.querySelector('ion-input .input-bottom');
|
||||
expect(bottomContent).toBe(null);
|
||||
});
|
||||
|
||||
it('should render bottom content when helper text is empty string', async () => {
|
||||
const page = await newSpecPage({
|
||||
components: [Input],
|
||||
html: `<ion-input label="Input" helper-text=""></ion-input>`,
|
||||
});
|
||||
|
||||
const bottomContent = page.body.querySelector('ion-input .input-bottom');
|
||||
expect(bottomContent).toBe(null);
|
||||
});
|
||||
});
|
||||
|
@ -1,32 +0,0 @@
|
||||
import { newSpecPage } from '@stencil/core/testing';
|
||||
import { Input } from '../input';
|
||||
|
||||
it('should render bottom content when helper text is defined', async () => {
|
||||
const page = await newSpecPage({
|
||||
components: [Input],
|
||||
html: `<ion-input label="Input" helper-text="Helper Text"></ion-input>`,
|
||||
});
|
||||
|
||||
const bottomContent = page.body.querySelector('ion-input .input-bottom');
|
||||
expect(bottomContent).not.toBe(null);
|
||||
});
|
||||
|
||||
it('should render bottom content when helper text is undefined', async () => {
|
||||
const page = await newSpecPage({
|
||||
components: [Input],
|
||||
html: `<ion-input label="Input"></ion-input>`,
|
||||
});
|
||||
|
||||
const bottomContent = page.body.querySelector('ion-input .input-bottom');
|
||||
expect(bottomContent).toBe(null);
|
||||
});
|
||||
|
||||
it('should render bottom content when helper text is empty string', async () => {
|
||||
const page = await newSpecPage({
|
||||
components: [Input],
|
||||
html: `<ion-input label="Input" helper-text=""></ion-input>`,
|
||||
});
|
||||
|
||||
const bottomContent = page.body.querySelector('ion-input .input-bottom');
|
||||
expect(bottomContent).toBe(null);
|
||||
});
|
Reference in New Issue
Block a user