chore(angular): remove radio value accessor (#28386)

Co-authored-by: Liam DeBeasi <liamdebeasi@users.noreply.github.com>
This commit is contained in:
Maria Hutt
2023-11-06 10:50:03 -08:00
committed by GitHub
parent 7ba939fb94
commit 098ed054b1
11 changed files with 64 additions and 74 deletions

View File

@@ -32,7 +32,8 @@ describe('Form', () => {
input2: 'Default Value',
inputMin: 1,
inputMax: 1,
checkbox: false
checkbox: false,
radio: null
});
});
@@ -59,7 +60,8 @@ describe('Form', () => {
input2: 'Default Value',
inputMin: 1,
inputMax: 1,
checkbox: false
checkbox: false,
radio: null
});
});
@@ -73,7 +75,8 @@ describe('Form', () => {
input2: 'Default Value',
inputMin: 1,
inputMax: 1,
checkbox: false
checkbox: false,
radio: null
});
});
@@ -87,7 +90,23 @@ describe('Form', () => {
input2: 'Default Value',
inputMin: 1,
inputMax: 1,
checkbox: true
checkbox: true,
radio: null
});
});
it('ion-radio should change', () => {
cy.get('ion-radio').click();
testData({
datetime: '2010-08-20',
select: null,
toggle: false,
input: '',
input2: 'Default Value',
inputMin: 1,
inputMax: 1,
checkbox: false,
radio: 'nes'
});
});
@@ -109,7 +128,8 @@ describe('Form', () => {
input2: 'Default Value',
inputMin: 1,
inputMax: 1,
checkbox: false
checkbox: false,
radio: null
});
cy.get('ion-checkbox').click();
testData({
@@ -120,7 +140,8 @@ describe('Form', () => {
input2: 'Default Value',
inputMin: 1,
inputMax: 1,
checkbox: true
checkbox: true,
radio: null
});
});
});

View File

@@ -5,6 +5,7 @@ describe('Inputs', () => {
it('should have default value', () => {
cy.get('ion-checkbox').should('have.prop', 'checked').and('equal', true);
cy.get('ion-radio-group').should('have.prop', 'value').and('equal', 'nes');
cy.get('ion-toggle').should('have.prop', 'checked').and('equal', true);
cy.get('ion-input').should('have.prop', 'value').and('equal', 'some text');
cy.get('ion-datetime').should('have.prop', 'value').and('equal', '1994-03-15');
@@ -15,6 +16,7 @@ describe('Inputs', () => {
cy.get('#reset-button').click();
cy.get('ion-checkbox').should('have.prop', 'checked').and('equal', false);
cy.get('ion-radio-group').should('not.have.prop', 'value');
cy.get('ion-toggle').should('have.prop', 'checked').and('equal', false);
/**
* The `value` property gets set to undefined
@@ -32,6 +34,7 @@ describe('Inputs', () => {
cy.get('#set-button').click();
cy.get('ion-checkbox').should('have.prop', 'checked').and('equal', true);
cy.get('ion-radio-group').should('have.prop', 'value').and('equal', 'nes');
cy.get('ion-toggle').should('have.prop', 'checked').and('equal', true);
cy.get('ion-input').should('have.prop', 'value').and('equal', 'some text');
cy.get('ion-datetime').should('have.prop', 'value').and('equal', '1994-03-15');
@@ -42,6 +45,7 @@ describe('Inputs', () => {
cy.get('#reset-button').click();
cy.get('ion-checkbox#first-checkbox').click();
cy.get('ion-radio').first().click();
cy.get('ion-toggle').first().click();
cy.get('ion-input').eq(0).type('hola');
@@ -58,6 +62,7 @@ describe('Inputs', () => {
cy.get('ion-alert .alert-button:not(.alert-button-role-cancel)').click();
cy.get('#checkbox-note').should('have.text', 'true');
cy.get('#radio-note').should('have.text', 'nes');
cy.get('#toggle-note').should('have.text', 'true');
cy.get('#input-note').should('have.text', 'hola');
cy.get('#datetime-note').should('have.text', '1994-03-14');

View File

@@ -48,6 +48,12 @@
<ion-checkbox formControlName="checkbox"> Checkbox </ion-checkbox>
</ion-item>
<ion-item>
<ion-radio-group formControlName="radio">
<ion-radio value="nes">Radio</ion-radio>
</ion-radio-group>
</ion-item>
<ion-item>
<ion-label>Min</ion-label>
<ion-input formControlName="inputMin" type="number"></ion-input>

View File

@@ -20,7 +20,8 @@ export class FormComponent {
input2: ['Default Value'],
inputMin: [1, Validators.min(1)],
inputMax: [1, Validators.max(1)],
checkbox: [false]
checkbox: [false],
radio: [undefined]
}, {
updateOn: typeof (window as any) !== 'undefined' && window.location.hash === '#blur' ? 'blur' : 'change'
});
@@ -44,7 +45,8 @@ export class FormComponent {
toggle: true,
input: 'Some value',
input2: 'Another values',
checkbox: true
checkbox: true,
radio: 'nes'
});
}

View File

@@ -85,6 +85,20 @@
<ion-note slot="end">{{checkbox}}</ion-note>
</ion-item>
<ion-item>
<ion-radio-group value="nes" [(ngModel)]="radio" id="first-radio">
<ion-radio value="nes">Radio</ion-radio>
</ion-radio-group>
<ion-note slot="end" id="radio-note">{{radio}}</ion-note>
</ion-item>
<ion-item color="dark">
<ion-radio-group value="nes" [(ngModel)]="radio">
<ion-radio value="nes">Radio Mirror</ion-radio>
</ion-radio-group>
<ion-note slot="end">{{radio}}</ion-note>
</ion-item>
</ion-list>
<p>
<ion-button (click)="setValues()" id="set-button">Set values</ion-button>

View File

@@ -9,6 +9,7 @@ export class InputsComponent {
datetime? = '1994-03-15';
input? = 'some text';
checkbox = true;
radio? = 'nes';
toggle = true;
select? = 'nes';
changes = 0;
@@ -18,6 +19,7 @@ export class InputsComponent {
this.datetime = '1994-03-15';
this.input = 'some text';
this.checkbox = true;
this.radio = 'nes';
this.toggle = true;
this.select = 'nes';
}
@@ -27,6 +29,7 @@ export class InputsComponent {
this.datetime = undefined;
this.input = undefined;
this.checkbox = false;
this.radio = undefined;
this.toggle = false;
this.select = undefined;
}