-
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.
- Loading branch information
1 parent
ae77332
commit c055c5d
Showing
17 changed files
with
1,027 additions
and
32 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 @@ | ||
coverage |
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
* text=auto | ||
*.rgba binary | ||
*.yuv binary |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.vscode | ||
build | ||
coverage | ||
libraries | ||
node_modules |
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 |
---|---|---|
@@ -1,10 +1,15 @@ | ||
.editorconfig | ||
.eslintignore | ||
.eslintrc.js | ||
.gitattributes | ||
.github | ||
.gitignore | ||
.npmignore | ||
.vscode | ||
**/*.spec.js | ||
build | ||
coverage | ||
jest.config.js | ||
jsconfig.json | ||
libraries | ||
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
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,4 @@ | ||
module.exports = { | ||
collectCoverage: true, | ||
collectCoverageFrom: ["source/**/*.js"] | ||
}; |
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,76 @@ | ||
const { readFileSync } = require("fs"); | ||
const { join } = require("path"); | ||
|
||
const { Format, decode } = require("."); | ||
|
||
const path = join(__dirname, "..", "test"); | ||
|
||
const rgba511 = readFileSync(join(path, "511x511.rgba")); | ||
|
||
const rgba512 = readFileSync(join(path, "512x512.rgba")); | ||
|
||
const webp511 = readFileSync(join(path, "511x511.webp")); | ||
|
||
const webp512 = readFileSync(join(path, "512x512.webp")); | ||
|
||
const yuv511 = readFileSync(join(path, "511x511.yuv")); | ||
|
||
const yuv512 = readFileSync(join(path, "512x512.yuv")); | ||
|
||
it("should decode an even-sized WebP as RGBA", async () => { | ||
const decoded = await decode(webp512, Format.rgba); | ||
expect(Buffer.from(decoded.data).equals(rgba512)).toBeTruthy(); | ||
expect(decoded.format).toBe(Format.rgba); | ||
expect(decoded.height).toBe(512); | ||
expect(decoded.width).toBe(512); | ||
}); | ||
|
||
it("should decode an odd-sized WebP as RGBA", async () => { | ||
const decoded = await decode(webp511, Format.rgba); | ||
expect(Buffer.from(decoded.data).equals(rgba511)).toBeTruthy(); | ||
expect(decoded.format).toBe(Format.rgba); | ||
expect(decoded.height).toBe(511); | ||
expect(decoded.width).toBe(511); | ||
}); | ||
|
||
it("should decode an even-sized WebP as YUV", async () => { | ||
const decoded = await decode(webp512, Format.yuv); | ||
expect(Buffer.from(decoded.data).equals(yuv512)).toBeTruthy(); | ||
expect(decoded.format).toBe(Format.yuv); | ||
expect(decoded.height).toBe(512); | ||
expect(decoded.width).toBe(512); | ||
}); | ||
|
||
it("should decode an odd-sized WebP as YUV", async () => { | ||
const decoded = await decode(webp511, Format.yuv); | ||
expect(Buffer.from(decoded.data).equals(yuv511)).toBeTruthy(); | ||
expect(decoded.format).toBe(Format.yuv); | ||
expect(decoded.height).toBe(512); | ||
expect(decoded.width).toBe(512); | ||
}); | ||
|
||
it("should throw when given no arguments", () => { | ||
expect(() => { | ||
decode(); | ||
}).toThrow(); | ||
}); | ||
|
||
it("should throw when the first argument is not a buffer", () => { | ||
expect(() => { | ||
decode(42); | ||
}).toThrow(); | ||
}); | ||
|
||
it("should throw when given a buffer that isn't a WebP", () => { | ||
return expect(decode(Buffer.from([1, 2, 3]))).rejects.toThrow(); | ||
}); | ||
|
||
it("should throw when given a format that isn't RGBA or YUV", () => { | ||
return expect(decode(webp512, 42)).rejects.toThrow(); | ||
}); | ||
|
||
it("shouldn't throw when given more than two arguments", () => { | ||
expect(() => { | ||
decode(webp512, Format.rgba, 42); | ||
}).not.toThrow(); | ||
}); |
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
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.