-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add testing to most files * Add node-pre-gyp for canvas-prebuilt * Run tests in travis * Fixes minor issues found by unit tests
- Loading branch information
Ben Pevsner
committed
Sep 13, 2018
1 parent
cecd1ea
commit 21cebd3
Showing
22 changed files
with
1,574 additions
and
753 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 |
---|---|---|
|
@@ -3,4 +3,4 @@ sudo: false | |
node_js: | ||
- "stable" | ||
|
||
script: npm run build | ||
script: npm run build && npm run test |
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,78 @@ | ||
import "canvas-prebuilt" | ||
|
||
global.chrome = { | ||
runtime: { | ||
lastError: null, | ||
onMessage: { | ||
addListener: jest.fn(), | ||
}, | ||
sendMessage: jest.fn(), | ||
}, | ||
|
||
storage: { | ||
sync: { | ||
get: jest.fn((value, callback) => { | ||
if (typeof callback === "function") callback() | ||
}), | ||
set: jest.fn((value, callback) => { | ||
if (typeof callback === "function") callback() | ||
}), | ||
} | ||
}, | ||
|
||
tabs: { | ||
get: jest.fn((tabId, callback) => { | ||
if (typeof callback === "function") callback() | ||
}), | ||
|
||
getCurrent: jest.fn(callback => { | ||
if (typeof callback === "function") callback(); | ||
}), | ||
|
||
sendMessage: jest.fn(), | ||
|
||
onUpdated: { | ||
addListener: jest.fn(), | ||
} | ||
}, | ||
}; | ||
|
||
global.customElements = { | ||
define: jest.fn(), | ||
}; | ||
|
||
global.testContext = { | ||
measureText: jest.fn(() => ({ width: 100 })), | ||
clearRect: jest.fn(), | ||
save: jest.fn(), | ||
scale: jest.fn(), | ||
fillText: jest.fn(), | ||
beginPath: jest.fn(), | ||
arc: jest.fn(), | ||
fill: jest.fn(), | ||
restore: jest.fn(), | ||
}; | ||
|
||
// HTML Elements | ||
[ "navlink", "navlink", "save", "save", "override-inputs" ] | ||
.forEach((name, index) => { | ||
const node = document.createElement("div"); | ||
node.className = name; | ||
node.appendChild(document.createTextNode(name + index)) | ||
document.body.appendChild(node); | ||
}); | ||
|
||
[ "page", "page" ] | ||
.forEach((name, index) => { | ||
const node = document.createElement("div"); | ||
node.className = "page navlink" + index; | ||
document.body.appendChild(node); | ||
}); | ||
|
||
[ "flag" ] | ||
.forEach(name => { | ||
const node = document.createElement("input"); | ||
node.type= "checkbox"; | ||
node.id = name; | ||
document.body.appendChild(node); | ||
}); |
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.