Skip to content

Commit

Permalink
test: processNode function
Browse files Browse the repository at this point in the history
  • Loading branch information
siemah committed Nov 1, 2019
1 parent c3d2265 commit 6b00342
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion __tests__/helpers.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { normaliseFieldName, } = require('../helpers/');
const { normaliseFieldName, processNode, } = require('../helpers/');

describe('Helpers:', () => {

Expand All @@ -7,4 +7,32 @@ describe('Helpers:', () => {
expect(normaliseFieldName('products/categories')).toEqual('productsCategories')
});

it('should creates processNode', () => {
const __type = 'wcProducts';
const nodeWithOutType = {
id: 1345,
categories: [{ id: 23 }],
wordpress_id: 1345,
};
const node = {
__type,
...nodeWithOutType
};
const contentDigest = 19;
const createContentDigest = jest.fn(() => contentDigest);
const processNodeResult = processNode(createContentDigest, node);

expect(createContentDigest).toBeCalled();
expect(processNodeResult).toEqual({
...nodeWithOutType,
parent: null,
children: [],
internal: {
type: __type,
contentDigest,
},
});

});

});

0 comments on commit 6b00342

Please sign in to comment.