Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite4d61f0

Browse files
committed
Add more tests
1 parent660f1dd commite4d61f0

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
##[1.0.1] - 2020-09-15
6+
7+
##Added
8+
- More tests
9+
510
##[1.0.0] - 2020-09-15
611

712
Initial release
813

14+
[1.0.1]:https://github.com/andreekeberg/imagedata/releases/tag/1.0.1
915
[1.0.0]:https://github.com/andreekeberg/imagedata/releases/tag/1.0.0

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"@andreekeberg/imagedata",
3-
"version":"1.0.0",
3+
"version":"1.0.1",
44
"description":"Unified method of getting ImageData from an image in both the browser and Node.js, either asynchronously or synchronously",
55
"main":"lib/node.js",
66
"module":"lib/node.js",

‎test/node.js‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import fs from 'fs'
44

55
constimagePath=`${__dirname}/images/hotdog.jpg`
66
constimageBuffer=fs.readFileSync(imagePath)
7+
constimageReadStream=fs.createReadStream(imagePath)
78

89
describe('Node',()=>{
910
describe('ImageData',()=>{
@@ -38,6 +39,42 @@ describe('Node', () => {
3839
it('should throw an error if callback is not a function',()=>{
3940
expect(()=>get('test.jpg',null)).to.throw(Error)
4041
})
42+
43+
it('should call provided callback with an ImageData instance when given a path',()=>{
44+
get(imagePath,(error,data)=>{
45+
assert.instanceOf(data,ImageData)
46+
})
47+
})
48+
49+
it('should call provided callback with an ImageData instance when given a Buffer',()=>{
50+
get(imageBuffer,(error,data)=>{
51+
assert.instanceOf(data,ImageData)
52+
})
53+
})
54+
55+
it('should call provided callback with an ImageData instance when given a ReadStream',()=>{
56+
get(imageReadStream,(error,data)=>{
57+
assert.instanceOf(data,ImageData)
58+
})
59+
})
60+
61+
it('callback data should include the correct image width',()=>{
62+
get(imagePath,(error,data)=>{
63+
expect(data.width).to.equal(500)
64+
})
65+
})
66+
67+
it('callback data should include the correct image height',()=>{
68+
get(imagePath,(error,data)=>{
69+
expect(data.height).to.equal(333)
70+
})
71+
})
72+
73+
it('callback data should include a Uint8ClampedArray',()=>{
74+
get(imagePath,(error,data)=>{
75+
assert.instanceOf(data.data,Uint8ClampedArray)
76+
})
77+
})
4178
})
4279

4380
describe('getSync',()=>{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp