mirror of
https://gitlab.silvrtree.co.uk/martind2000/ft-webplatform.git
synced 2025-01-25 19:26:17 +00:00
25 lines
792 B
JavaScript
25 lines
792 B
JavaScript
/**
|
|
* Test Utils for reducers
|
|
*
|
|
* E.g. setJSONFixture('src/components/products/performance/ft-discrete-returns/lib/etf/mock-new-state-out.fixture.json', newState);
|
|
*/
|
|
|
|
/**
|
|
* synchronously save JSON fixture file
|
|
* @parameter {string} filename eg /components/products/pricing-distribution/ft-pricing-distribution/lib/gw/mock-new-state-out.fixture.json
|
|
* @parameter {Object} obj file to stringify and store in file
|
|
*/
|
|
export function setJSONFixture(filename, obj) {
|
|
const fs = require('fs');
|
|
fs.writeFileSync(filename, JSON.stringify(obj, null, ' '));
|
|
}
|
|
|
|
/**
|
|
* edit a object to remove undefineds and make flat
|
|
* @parameter {Object} obj file to stringify and store in file
|
|
* @return {Object}
|
|
*/
|
|
export function removeUndefineds(obj) {
|
|
return JSON.parse(JSON.stringify(obj));
|
|
}
|