-
Notifications
You must be signed in to change notification settings - Fork 903
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1045 from ml5js/joeyklee.637-mock-functions-in-tests
[testing]: mocks objectDetector functions
- Loading branch information
Showing
6 changed files
with
76 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
export const getRobin = async () => { | ||
const img = new Image(); | ||
img.crossOrigin = ""; | ||
img.src = "https://cdn.jsdelivr.net/gh/ml5js/ml5-library@development/assets/bird.jpg"; | ||
await new Promise(resolve => { | ||
img.onload = resolve; | ||
}); | ||
return img; | ||
} | ||
|
||
export const getImageData = async () => { | ||
const arr = new Uint8ClampedArray(20000); | ||
|
||
// Iterate through every pixel | ||
for (let i = 0; i < arr.length; i += 4) { | ||
arr[i + 0] = 0; // R value | ||
arr[i + 1] = 190; // G value | ||
arr[i + 2] = 0; // B value | ||
arr[i + 3] = 255; // A value | ||
} | ||
|
||
// Initialize a new ImageData object | ||
const img = new ImageData(arr, 200); | ||
return img; | ||
} |