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.
fix: match latest changes in jest-canvas-mock
- Loading branch information
Showing
20 changed files
with
254 additions
and
72 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
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
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
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
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
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
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,47 @@ | ||
import { JSDOM } from 'jsdom'; | ||
import mockWindow from '../../src/window'; | ||
|
||
describe('mockWindow', () => { | ||
it('mocks the passed object', () => { | ||
const win = new JSDOM().window; | ||
|
||
mockWindow(win); | ||
|
||
expect(win.Path2D).not.toBeNull(); | ||
expect(win.CanvasGradient).not.toBeNull(); | ||
expect(win.CanvasPattern).not.toBeNull(); | ||
expect(win.CanvasRenderingContext2D).not.toBeNull(); | ||
expect(win.DOMMatrix).not.toBeNull(); | ||
expect(win.ImageData).not.toBeNull(); | ||
expect(win.TextMetrics).not.toBeNull(); | ||
expect(win.ImageBitmap).not.toBeNull(); | ||
expect(win.createImageBitmap).not.toBeNull(); | ||
|
||
expect( | ||
jest.isMockFunction(win.HTMLCanvasElement.prototype.getContext) | ||
).toBe(true); | ||
expect(jest.isMockFunction(win.HTMLCanvasElement.prototype.toBlob)).toBe( | ||
true | ||
); | ||
expect(jest.isMockFunction(win.HTMLCanvasElement.prototype.toDataURL)).toBe( | ||
true | ||
); | ||
}); | ||
|
||
it('mocks without a fully formed passed in window object', () => { | ||
const win = mockWindow({ document: {} }); | ||
|
||
expect(win.Path2D).not.toBeNull(); | ||
expect(win.CanvasGradient).not.toBeNull(); | ||
expect(win.CanvasPattern).not.toBeNull(); | ||
expect(win.CanvasRenderingContext2D).not.toBeNull(); | ||
expect(win.DOMMatrix).not.toBeNull(); | ||
expect(win.ImageData).not.toBeNull(); | ||
expect(win.TextMetrics).not.toBeNull(); | ||
expect(win.ImageBitmap).not.toBeNull(); | ||
expect(win.createImageBitmap).not.toBeNull(); | ||
|
||
expect(jest.isMockFunction(win.HTMLCanvasElement)).toBe(false); | ||
expect(win.HTMLCanvasElement).toBeUndefined(); | ||
}); | ||
}); |
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
Oops, something went wrong.