Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

Updated Gatsby mock: fluid images returned by useStaticQuery

gianantoniopini942d8a012027
diff --git a/__mocks__/gatsby.js b/__mocks__/gatsby.js
index c9c0bae4f..fa0835ad1 100644
--- a/__mocks__/gatsby.js
+++ b/__mocks__/gatsby.js
@@ -1,8 +1,28 @@
-const React = require(`react`);
-const gatsby = jest.requireActual(`gatsby`);
+import React from 'react';
+const Gatsby = jest.requireActual('gatsby');
+
+const fluidImagesShapeMock = [
+ {
+ aspectRatio: 2,
+ src: `test_image.jpg`,
+ srcSet: `some srcSet`,
+ srcSetWebp: `some srcSetWebp`,
+ sizes: `(max-width: 600px) 100vw, 600px`,
+ base64: `string_of_base64`,
+ },
+ {
+ aspectRatio: 3,
+ src: `test_image_2.jpg`,
+ srcSet: `some other srcSet`,
+ srcSetWebp: `some other srcSetWebp`,
+ sizes: `(max-width: 600px) 100vw, 600px`,
+ base64: `string_of_base64`,
+ media: `only screen and (min-width: 768px)`,
+ },
+];
module.exports = {
- ...gatsby,
+ ...Gatsby,
graphql: jest.fn(),
Link: jest.fn().mockImplementation(({ to, ...rest }) =>
React.createElement(`a`, {
@@ -22,13 +42,7 @@ module.exports = {
},
file: {
childImageSharp: {
- fluid(maxWidth = 512) {
- base64;
- aspectRatio;
- src;
- srcSet;
- sizes;
- },
+ fluid: fluidImagesShapeMock[0],
},
},
}),