@@ -4,6 +4,7 @@ import fs from 'fs'
44
55const imagePath = `${ __dirname } /images/hotdog.jpg`
66const imageBuffer = fs . readFileSync ( imagePath )
7+ const imageReadStream = fs . createReadStream ( imagePath )
78
89describe ( 'Node' , ( ) => {
910describe ( 'ImageData' , ( ) => {
@@ -38,6 +39,42 @@ describe('Node', () => {
3839it ( 'should throw an error if callback is not a function' , ( ) => {
3940expect ( ( ) => 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
4380describe ( 'getSync' , ( ) => {