forked from niklasvh/html2canvas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly respect logging option (niklasvh#2013)
* test: update to using jest for unit tests * remove mocha types * revert to using mocha for testrunner.ts * add logger unit testing * fix reftest previewer scaling * fix LoggerOptions to interface * fix linting
- Loading branch information
Showing
17 changed files
with
2,624 additions
and
236 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,5 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'jsdom', | ||
roots: ['src'] | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
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,22 @@ | ||
class MockCache { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
private readonly _cache: {[key: string]: Promise<any>}; | ||
|
||
constructor() { | ||
this._cache = {}; | ||
} | ||
|
||
addImage(src: string): Promise<void> { | ||
const result = Promise.resolve(); | ||
this._cache[src] = result; | ||
return result; | ||
} | ||
} | ||
|
||
const current = new MockCache(); | ||
|
||
export class CacheStorage { | ||
static getInstance(): MockCache { | ||
return current; | ||
} | ||
} |
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,8 @@ | ||
export const FEATURES = { | ||
SUPPORT_RANGE_BOUNDS: true, | ||
SUPPORT_SVG_DRAWING: true, | ||
SUPPORT_FOREIGNOBJECT_DRAWING: true, | ||
SUPPORT_CORS_IMAGES: true, | ||
SUPPORT_RESPONSE_TYPE: true, | ||
SUPPORT_CORS_XHR: true | ||
}; |
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,27 @@ | ||
import {Logger} from '../logger'; | ||
|
||
describe('logger', () => { | ||
let infoSpy: any; | ||
|
||
beforeEach(() => { | ||
infoSpy = jest.spyOn(console, 'info').mockImplementation(() => {}); | ||
}); | ||
|
||
afterEach(() => { | ||
infoSpy.mockRestore(); | ||
}); | ||
|
||
it('should call console.info when logger enabled', () => { | ||
const id = Math.random().toString(); | ||
const logger = new Logger({id, enabled: true}); | ||
logger.info('testing'); | ||
expect(infoSpy).toHaveBeenLastCalledWith(id, expect.stringMatching(/\d+ms/), 'testing'); | ||
}); | ||
|
||
it("shouldn't call console.info when logger disabled", () => { | ||
const id = Math.random().toString(); | ||
const logger = new Logger({id, enabled: false}); | ||
logger.info('testing'); | ||
expect(infoSpy).not.toHaveBeenCalled(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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,6 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"types": ["node", "mocha"] | ||
} | ||
} |
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