forked from hustcc/jest-canvas-mock
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(canvas): add roundRect (hustcc#105) (hustcc#119)
- Loading branch information
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
let canvas; | ||
let ctx; | ||
|
||
beforeEach(() => { | ||
canvas = document.createElement('canvas'); | ||
ctx = canvas.getContext('2d'); | ||
canvas.width = 400; | ||
canvas.height = 300; | ||
}); | ||
|
||
describe('roundRect', () => { | ||
it('should be a function', () => { | ||
expect(typeof ctx.roundRect).toBe('function'); | ||
}); | ||
|
||
it('should be callable', () => { | ||
ctx.roundRect(1, 2, 3, 4, [5, 6, 7, 8]); | ||
expect(ctx.roundRect).toBeCalled(); | ||
}); | ||
|
||
it('should throw if less than 4 parameters are given', () => { | ||
expect(() => ctx.roundRect()).toThrow(TypeError); | ||
expect(() => ctx.roundRect(1)).toThrow(TypeError); | ||
expect(() => ctx.roundRect(1, 2)).toThrow(TypeError); | ||
expect(() => ctx.roundRect(1, 2, 3)).toThrow(TypeError); | ||
}); | ||
|
||
describe('radii parameter', () => { | ||
it('should throw if is an empty array', () => { | ||
expect(() => ctx.roundRect(1, 2, 3, 4, [])).toThrow(TypeError); | ||
}); | ||
|
||
it('should throw if has more than 4 elements', () => { | ||
expect(() => ctx.roundRect(1, 2, 3, 4, [1, 2, 3, 4, 5])).toThrow( | ||
TypeError | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters