-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
39fe05b
commit f17f914
Showing
3 changed files
with
76 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
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