Skip to content

Commit

Permalink
fixes eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ifrim committed Feb 25, 2024
1 parent 9c7b416 commit ff27f02
Show file tree
Hide file tree
Showing 82 changed files with 1,397 additions and 1,186 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ coverage
.nyc_output
*DS_Store
cypress/screenshots
.vscode
62 changes: 31 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
"css-loader": "6.8.1",
"cypress": "13.6.1",
"esbuild-loader": "4.0.2",
"eslint": "8.55.0",
"eslint": "8.57.0",
"eslint-config-airbnb": "19.0.4",
"eslint-plugin-cypress": "2.15.1",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jsx-a11y": "6.8.0",
"eslint-plugin-react": "7.33.2",
"eslint-plugin-react-hooks": "4.6.0",
Expand Down
10 changes: 6 additions & 4 deletions src/components/Accordion/js/AccordionItem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ describe('AccordionItem', () => {
.get(selectors.itemActive)
.should('exist')
.get(selectors.trigger)
.click()
.get(selectors.itemActive)
.click();

cy.get(selectors.itemActive)
.should('not.exist');
});

Expand All @@ -60,8 +61,9 @@ describe('AccordionItem', () => {
.get(selectors.itemActive)
.should('exist')
.get(selectors.trigger)
.click()
.get(selectors.itemActive)
.click();

cy.get(selectors.itemActive)
.should('exist');
});
});
1 change: 1 addition & 0 deletions src/components/Accordion/js/AccordionItemTrigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function ItemTrigger({ wrap }) {
className={classes}
onClick={toggleChange}
type="button"
aria-label="collapse/expand"
>
<Icon className="collapsable__arrow" type={iconType} />
</button>
Expand Down
16 changes: 10 additions & 6 deletions src/components/Button/Button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('Button', () => {
});

it('should call the onClick callback', () => {
const onClick = cy.stub();
const onClick = cy.stub().as('onClick');

cy
.mount(
Expand All @@ -96,12 +96,14 @@ describe('Button', () => {
);

cy.contains(buttonText)
.click()
.then(() => expect(onClick).to.be.called);
.click();

cy.get('@onClick')
.should('be.called');
});

it('should not call the onClick callback if disabled', () => {
const onClick = cy.stub();
const onClick = cy.stub().as('onClick');

cy
.mount(
Expand All @@ -115,7 +117,9 @@ describe('Button', () => {
);

cy.contains(buttonText)
.click({ force: true })
.then(() => expect(onClick).not.to.be.called);
.click({ force: true });

cy.get('@onClick')
.should('not.be.called');
});
});
12 changes: 5 additions & 7 deletions src/components/Button/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Fragment, cloneElement } from 'react';
import React, { cloneElement } from 'react';
import PropTypes from 'prop-types';

import Icon from '../Icon';
Expand Down Expand Up @@ -65,13 +65,12 @@ const Button = React.forwardRef((props, ref) => {

if (customButton) {
return (
<Fragment>
<>
{ cloneElement(customButton, {
className: getCssClasses(),
disabled,
})
}
</Fragment>
})}
</>
);
}

Expand Down Expand Up @@ -99,7 +98,7 @@ const Button = React.forwardRef((props, ref) => {
className={getCssClasses()}
disabled={disabled}
onClick={onClick}
type={type || 'button'}
type={type || 'button'} // eslint-disable-line react/button-has-type
ref={ref}
{...rest}
>
Expand All @@ -113,7 +112,6 @@ const Button = React.forwardRef((props, ref) => {
return buttonType;
};


return (
getButtonType()
);
Expand Down
13 changes: 8 additions & 5 deletions src/components/Collapsible/Collapsible.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ describe('Collapsible', () => {
);
}

// eslint-disable-next-line cypress/no-unnecessary-waiting
cy
.mount(<Component />)
.get(wrapperSelector)
Expand All @@ -87,16 +86,20 @@ describe('Collapsible', () => {

.get('button')
.contains('large')
.click()
.wait(200)
.click();

// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(200)
.get(wrapperSelector)
.invoke('height')
.should('be.gt', epsilon)

.get('button')
.contains('small')
.click()
.wait(200)
.click();

// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(200)
.get(wrapperSelector)
.invoke('height')
.should('be.lt', epsilon);
Expand Down
45 changes: 24 additions & 21 deletions src/components/Confirm/Confirm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ describe('Confirm', () => {
.get(selectors.modalBackdrop)
.should('not.have.class', 'opened')
.get(selectors.contentButton)
.click()
.get(selectors.modalBackdrop)
.click();

cy.get(selectors.modalBackdrop)
.should('have.class', 'opened');
});

Expand Down Expand Up @@ -82,45 +83,47 @@ describe('Confirm', () => {

it('calls the confirmCallback when clicking on the confirm button', () => {
const confirmBtnText = 'Custom Confirm';
const confirmCallback = cy.stub();
const confirmCallback = cy.stub().as('confirmCallback');

cy
.mount(<Component confirmBtnText={confirmBtnText} confirmCallback={confirmCallback} />)
.get(selectors.contentButton)
.click()
.get('button')
.click();

cy.get('button')
.contains(confirmBtnText)
.click()
.then(() => {
expect(confirmCallback).to.be.called;
});
.click();

cy.get('@confirmCallback')
.should('be.called');
});

it('calls the cancelCallback when clicking on the confirm button', () => {
const cancelBtnText = 'Custom Cancel';
const cancelCallback = cy.stub();
const cancelCallback = cy.stub().as('cancelCallback');

cy
.mount(<Component cancelBtnText={cancelBtnText} cancelCallback={cancelCallback} />)
.get(selectors.contentButton)
.click()
.get('button')
.click();

cy.get('button')
.contains(cancelBtnText)
.click()
.then(() => {
expect(cancelCallback).to.be.called;
});
.click();

cy.get('@cancelCallback')
.should('be.called');
});

it('calls the beforeCallback when showing the modal', () => {
const beforeCallback = cy.stub();
const beforeCallback = cy.stub().as('beforeCallback');

cy
.mount(<Component beforeCallback={beforeCallback} />)
.get(selectors.contentButton)
.click()
.then(() => {
expect(beforeCallback).to.be.called;
});
.click();

cy.get('@beforeCallback')
.should('be.called');
});
});
4 changes: 2 additions & 2 deletions src/components/Confirm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ function Confirm(props) {
</Modal.Body>
<Modal.Footer>
<Button
onClick={cancel}
theme="default"
onClick={cancel}
theme="default"
>
{cancelBtnText}
</Button>
Expand Down
Loading

0 comments on commit ff27f02

Please sign in to comment.