chore(): sync with main

This commit is contained in:
Liam DeBeasi
2022-12-08 12:39:38 -05:00
457 changed files with 939 additions and 3118 deletions

View File

@ -0,0 +1,43 @@
import { newSpecPage } from '@stencil/core/testing';
import { config } from '../../../global/config';
import { Toggle } from '../toggle';
describe('toggle', () => {
beforeEach(() => {
config.reset({});
});
const newToggle = async (): Promise<Toggle> => {
const { rootInstance } = await newSpecPage({
components: [Toggle],
html: `<ion-toggle></ion-toggle>`,
});
return rootInstance;
};
describe('enableOnOffLabels', () => {
it('should disable on/off labels when setting to false on component', async () => {
const t = await newToggle();
t.enableOnOffLabels = false;
config.reset({
toggleOnOffLabels: true,
});
expect(t.enableOnOffLabels).toBe(false);
});
it('should enable on/off labels when setting to true on global config', async () => {
config.reset({
toggleOnOffLabels: true,
});
const t = await newToggle();
expect(t.enableOnOffLabels).toBe(true);
});
it('should enable on/off labels when setting to true on component', async () => {
const t = await newToggle();
t.enableOnOffLabels = true;
expect(t.enableOnOffLabels).toBe(true);
});
});
});

View File

@ -3,6 +3,7 @@ import { Component, Element, Event, Host, Prop, State, Watch, h } from '@stencil
// TODO(FW-2845) - Use @utils/forms and @utils/logging when https://github.com/ionic-team/stencil/issues/3826 is resolved
import { checkmarkOutline, removeOutline, ellipseOutline } from 'ionicons/icons';
import { config } from '../../global/config';
import { getIonMode } from '../../global/ionic-global';
import type { Color, Gesture, GestureDetail, Mode, StyleEventDetail, ToggleChangeEventDetail } from '../../interface';
import type { LegacyFormController } from '../../utils/forms';
@ -79,7 +80,7 @@ export class Toggle implements ComponentInterface {
/**
* Enables the on/off accessibility switch labels within the toggle.
*/
@Prop() enableOnOffLabels: boolean | undefined = undefined;
@Prop() enableOnOffLabels: boolean | undefined = config.get('toggleOnOffLabels');
/**
* Where to place the label relative to the input.