Skip to content

Commit

Permalink
update Button-test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
hayanisaid committed Aug 8, 2022
1 parent 8be0ae1 commit 7b161c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/react-ape/renderer/elements/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function renderButton(

//set the fontSize
const fontArgs = ctx.font.split(' ');
const newSize = ` ${ButtonDefaults.textStyle.fontSize}px`;
const newSize = `${ButtonDefaults.textStyle.fontSize}px`;
ctx.font = newSize + ' ' + fontArgs[fontArgs.length - 1];

// ctx.textAlign = 'center';
Expand Down
14 changes: 9 additions & 5 deletions packages/react-ape/renderer/elements/__tests__/Button-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Button', () => {
const title = 'Press Me';
const color = '#f8a978';
const x = 40;
const y = 20;
const y = 300;
const width = x + y;
const height = ButtonDefaults.containerStyle.height;
const props = {title, color};
Expand All @@ -25,7 +25,11 @@ describe('Button', () => {
lineTo: jest.fn(),
quadraticCurveTo: jest.fn(),
font: 'Helvetica',
measureText: jest.fn(),
measureText: jest.fn(() => {
return {
width: 100,
};
}),
canvas: {
addEventListener: jest.fn(),
},
Expand Down Expand Up @@ -54,10 +58,10 @@ describe('Button', () => {
expect(lineTo.mock.calls.length).toEqual(4);
expect(fill.mock.calls.length).toBe(1);
expect(fillText.mock.calls.length).toBe(1);
expect(fillText).toBeCalledWith(title, x + width / 2, y + height / 2);
expect(font).toEqual(`${ButtonDefaults.textStyle.fontSize} Helvetica`);
expect(fillText.mock.calls.length).toBe(1);
expect(font).toEqual(`${ButtonDefaults.textStyle.fontSize}px Helvetica`);
expect(quadraticCurveTo.mock.calls.length).toEqual(4);
expect(fillStyle).toBe(color);
expect(fillStyle).toEqual('white');
expect(Button).toMatchSnapshot();
});
});
Expand Down

0 comments on commit 7b161c6

Please sign in to comment.