@@ -25,14 +25,19 @@ const node: Node = {
2525 } ,
2626}
2727
28- const dataParent = {
28+ const imageDataParent = {
2929 ...node ,
3030 gatsbyImageData : imageData ,
3131}
3232
33+ const imageParent = {
34+ ...node ,
35+ gatsbyImage : imageData ,
36+ }
37+
3338const fileNode = {
3439 ...node ,
35- childImageSharp : dataParent ,
40+ childImageSharp : imageDataParent ,
3641}
3742
3843const getImageDataArgs : IGetImageDataArgs = {
@@ -147,13 +152,21 @@ describe(`The image helper functions`, () => {
147152 it ( `returns the same data if passed gatsbyImageData` , ( ) => {
148153 expect ( getImage ( imageData ) ) . toEqual ( imageData )
149154 } )
155+ it ( `returns the same data if passed gatsbyImage` , ( ) => {
156+ expect ( getImage ( imageData ) ) . toEqual ( imageData )
157+ } )
150158
151159 it ( `gets an image from a FileNode` , ( ) => {
152160 expect ( getImage ( fileNode ) ?. images . fallback ?. src ) . toEqual ( `imagesrc.jpg` )
153161 } )
154162
155- it ( `gets an image from an IGatsbyImageDataParent` , ( ) => {
156- expect ( getImage ( dataParent ) ?. images . fallback ?. src ) . toEqual ( `imagesrc.jpg` )
163+ it ( `gets an image from an IGatsbyImageDataParent/IGatsbyImageParent` , ( ) => {
164+ expect ( getImage ( imageDataParent ) ?. images . fallback ?. src ) . toEqual (
165+ `imagesrc.jpg`
166+ )
167+ expect ( getImage ( imageParent ) ?. images . fallback ?. src ) . toEqual (
168+ `imagesrc.jpg`
169+ )
157170 } )
158171 it ( `returns undefined from an invalid object` , ( ) => {
159172 expect ( getImage ( node ) ) . toBeUndefined ( )
@@ -177,8 +190,9 @@ describe(`The image helper functions`, () => {
177190 expect ( getSrc ( fileNode ) ) . toEqual ( `imagesrc.jpg` )
178191 } )
179192
180- it ( `gets src from an IGatsbyImageDataParent` , ( ) => {
181- expect ( getSrc ( dataParent ) ) . toEqual ( `imagesrc.jpg` )
193+ it ( `gets src from an IGatsbyImageDataParent/IGatsbyImageParent` , ( ) => {
194+ expect ( getSrc ( imageDataParent ) ) . toEqual ( `imagesrc.jpg` )
195+ expect ( getSrc ( imageParent ) ) . toEqual ( `imagesrc.jpg` )
182196 } )
183197
184198 it ( `returns undefined from an invalid object` , ( ) => {
@@ -202,8 +216,9 @@ describe(`The image helper functions`, () => {
202216 expect ( getSrcSet ( fileNode ) ) . toEqual ( `imagesrcset.jpg 1x` )
203217 } )
204218
205- it ( `gets srcSet from an IGatsbyImageDataParent` , ( ) => {
206- expect ( getSrcSet ( dataParent ) ) . toEqual ( `imagesrcset.jpg 1x` )
219+ it ( `gets srcSet from an IGatsbyImageDataParent/IGatsbyImageParent` , ( ) => {
220+ expect ( getSrcSet ( imageDataParent ) ) . toEqual ( `imagesrcset.jpg 1x` )
221+ expect ( getSrcSet ( imageParent ) ) . toEqual ( `imagesrcset.jpg 1x` )
207222 } )
208223
209224 it ( `returns undefined from an invalid object` , ( ) => {
0 commit comments