How to use the lightning/testUtilsButtonGroup.generateRandomButtonsArray function in lightning

To help you get started, we’ve selected a few lightning examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github salesforce / base-components-recipes / force-app / main / default / lwc / buttonGroup / __test__ / buttonGroup.spec.js View on Github external
it.skip('each child button element should have the correct position/order SLDS class when a button is prepended', () => {
        const numButtons = 5;
        const numButtonStatefuls = 1;
        const numButtonIcons = 2;
        const numButtonIconStatefuls = 2;
        const numButtonMenus = 1;
        const totalNumChildren =
            numButtons +
            numButtonStatefuls +
            numButtonIcons +
            numButtonIconStatefuls +
            numButtonMenus;

        const buttons = buttonGroupUtils.generateRandomButtonsArray(numButtons);
        const buttonStatefuls = buttonGroupUtils.generateRandomButtonStatefulsArray(
            numButtonStatefuls
        );

        const buttonIcons = buttonGroupUtils.generateRandomButtonIconsArray(
            numButtonIcons
        );

        const buttonIconStatefuls = buttonGroupUtils.generateRandomButtonIconStatefulsArray(
            numButtonIconStatefuls
        );

        const buttonMenus = buttonGroupUtils.generateRandomButtonMenusArray(
            numButtonMenus
        );
github salesforce / base-components-recipes / force-app / main / default / lwc / buttonGroup / __test__ / buttonGroup.spec.js View on Github external
return Promise.resolve().then(() => {
            buttons.unshift(buttonGroupUtils.generateRandomButtonsArray(1)[0]);
            element.buttons = buttons;

            return Promise.resolve().then(() => {
                return Promise.resolve().then(() => {
                    const children = element.querySelector('slot').children;

                    expect(children).toHaveLength(totalNumChildren + 1);

                    const hasFirstClass = shadowQuerySelector(
                        children[0],
                        '.slds-button'
                    ).classList.contains('slds-button_first');
                    expect(hasFirstClass).toBe(true);

                    for (let i = 1; i < children.length - 2; i++) {
                        const hasMiddleClass = shadowQuerySelector(
github salesforce / base-components-recipes / force-app / main / default / lwc / buttonGroup / __test__ / buttonGroup.spec.js View on Github external
it.skip('when only one button element is present it should have no position/order SLDS class', () => {
        const numButtons = 1;
        const buttons = buttonGroupUtils.generateRandomButtonsArray(numButtons);
        const element = createButtonGroup({
            buttons
        });

        return Promise.resolve().then(() => {
            const children = element.querySelector('slot').children;

            expect(children).toHaveLength(numButtons);

            const hasFirstClass = shadowQuerySelector(
                children[0],
                '.slds-button'
            ).classList.contains('slds-button_first');
            expect(hasFirstClass).toBe(false);
        });
    });
github salesforce / base-components-recipes / force-app / main / default / lwc / buttonGroup / __test__ / buttonGroup.spec.js View on Github external
it.skip('each child button element should have the correct position/order SLDS class when a button is appended', () => {
        const numButtons = 4;
        const numButtonStatefuls = 1;
        const numButtonIcons = 2;
        const numButtonIconStatefuls = 2;
        const numButtonMenus = 1;
        const totalNumChildren =
            numButtons +
            numButtonStatefuls +
            numButtonIcons +
            numButtonIconStatefuls +
            numButtonMenus;

        const buttons = buttonGroupUtils.generateRandomButtonsArray(numButtons);
        const buttonStatefuls = buttonGroupUtils.generateRandomButtonStatefulsArray(
            numButtonStatefuls
        );

        const buttonIcons = buttonGroupUtils.generateRandomButtonIconsArray(
            numButtonIcons
        );

        const buttonIconStatefuls = buttonGroupUtils.generateRandomButtonIconStatefulsArray(
            numButtonIconStatefuls
        );

        const buttonMenus = buttonGroupUtils.generateRandomButtonMenusArray(
            numButtonMenus
        );
github salesforce / base-components-recipes / force-app / main / default / lwc / buttonGroup / __test__ / buttonGroup.spec.js View on Github external
it.skip('each child button element should have the correct position/order SLDS class when a button is inserted', () => {
        const numButtons = 4;
        const numButtonStatefuls = 1;
        const numButtonIcons = 2;
        const numButtonIconStatefuls = 2;
        const numButtonMenus = 1;
        const totalNumChildren =
            numButtons +
            numButtonStatefuls +
            numButtonIcons +
            numButtonIconStatefuls +
            numButtonMenus;

        const buttons = buttonGroupUtils.generateRandomButtonsArray(numButtons);
        const buttonStatefuls = buttonGroupUtils.generateRandomButtonStatefulsArray(
            numButtonStatefuls
        );

        const buttonIcons = buttonGroupUtils.generateRandomButtonIconsArray(
            numButtonIcons
        );

        const buttonIconStatefuls = buttonGroupUtils.generateRandomButtonIconStatefulsArray(
            numButtonIconStatefuls
        );

        const buttonMenus = buttonGroupUtils.generateRandomButtonMenusArray(
            numButtonMenus
        );
github salesforce / base-components-recipes / force-app / main / default / lwc / buttonGroup / __test__ / buttonGroup.spec.js View on Github external
it.skip('when button list is reduced to only one button element the button should have no position/order SLDS class', () => {
        const numButtons = 2;
        const buttons = buttonGroupUtils.generateRandomButtonsArray(numButtons);
        const element = createButtonGroup({
            buttons
        });

        return Promise.resolve().then(() => {
            buttons.splice(1);
            element.buttons = buttons;

            return Promise.resolve().then(() => {
                return Promise.resolve().then(() => {
                    const children = element.querySelector('slot').children;

                    expect(children).toHaveLength(1);

                    const hasFirstClass = shadowQuerySelector(
                        children[0],
github salesforce / base-components-recipes / force-app / main / default / lwc / buttonGroup / __test__ / buttonGroup.spec.js View on Github external
it.skip('should have the correct number of child button elements', () => {
        const numButtons = 4;
        const numButtonStatefuls = 1;
        const numButtonIcons = 2;
        const numButtonIconStatefuls = 2;
        const numButtonMenus = 1;
        const totalNumChildren =
            numButtons +
            numButtonStatefuls +
            numButtonIcons +
            numButtonIconStatefuls +
            numButtonMenus;

        const element = createButtonGroup({
            buttons: buttonGroupUtils.generateRandomButtonsArray(numButtons),
            buttonStatefuls: buttonGroupUtils.generateRandomButtonStatefulsArray(
                numButtonStatefuls
            ),

            buttonIcons: buttonGroupUtils.generateRandomButtonIconsArray(
                numButtonIcons
            ),

            buttonIconStatefuls: buttonGroupUtils.generateRandomButtonIconStatefulsArray(
                numButtonIconStatefuls
            ),

            buttonMenus: buttonGroupUtils.generateRandomButtonMenusArray(
                numButtonMenus
            )
        });