Skip to content

Commit

Permalink
chore(Rating): improve tests by codereview
Browse files Browse the repository at this point in the history
  • Loading branch information
YSMJ1994 authored and eternalsky committed Mar 28, 2024
1 parent 33af090 commit 8b0996c
Showing 1 changed file with 4 additions and 25 deletions.
29 changes: 4 additions & 25 deletions components/rating/__tests__/index-spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,13 @@ describe('Rating', () => {
});
});

describe.only('action', () => {
// let ret, hval, parent, rect, onChange, onHoverChange;

// beforeEach(() => {
// ret = -1;
// hval = -1;
// parent = document.createElement('div');
// document.body.appendChild(parent);
// onChange = function (val) {
// return (ret = val);
// };
// onHoverChange = function (val) {
// return (hval = val);
// };
// });

// afterEach(() => {
// document.body.removeChild(parent);
// parent = null;
// rect = null;
// onChange = null;
// onHoverChange = null;
// });

describe('action', () => {
it('should be controlled ', () => {
cy.mount(<Rating value={3} />);
const onChange = cy.spy();
cy.mount(<Rating value={3} onChange={onChange} />);
cy.get('.next-rating-overlay').should('have.css', 'width', '64px');
triggerPosition(8, 8, 'click');
cy.wrap(onChange).should('be.calledOnceWith', 1);
cy.get('.next-rating-overlay').should('have.css', 'width', '64px');
});

Expand Down

0 comments on commit 8b0996c

Please sign in to comment.