Improve caching, fix Firefox private mode usage #205
@@ -1,4 +1,4 @@
|
||||
export default function processContributionData(data) {
|
||||
export default function processContributionData(data, options={}) {
|
||||
const processed = {}
|
||||
|
||||
if (data.confirmedAtBlock && (typeof data.confirmedAtBlock.toNumber === 'function')) {
|
||||
@@ -9,12 +9,16 @@ export default function processContributionData(data) {
|
||||
|
||||
const otherProperties = [
|
||||
'id', 'contributorId', 'amount', 'vetoed', 'ipfsHash', 'kind',
|
||||
'description', 'details', 'url', 'date', 'time', 'pendingTx'
|
||||
'description', 'url', 'date', 'time', 'pendingTx'
|
||||
];
|
||||
|
||||
otherProperties.forEach(prop => {
|
||||
processed[prop] = data[prop];
|
||||
});
|
||||
|
||||
if (options.includeDetails) {
|
||||
processed.details = data.details;
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
@@ -4,16 +4,18 @@ import testData from '../../fixtures/contribution-data';
|
||||
|
||||
module('Unit | Utility | process-contribution-data', function() {
|
||||
|
||||
let result = processContributionData(testData);
|
||||
|
||||
test('formats the data correctly', function(assert) {
|
||||
const result = processContributionData(testData);
|
||||
|
||||
assert.ok(typeof result.confirmedAt === 'number');
|
||||
});
|
||||
|
||||
test('copies other properties', function(assert) {
|
||||
const result = processContributionData(testData);
|
||||
|
||||
[
|
||||
'id', 'contributorId', 'amount', 'vetoed',
|
||||
'ipfsHash', 'kind', 'description', 'details',
|
||||
'ipfsHash', 'kind', 'description',
|
||||
'url', 'date', 'time', 'pendingTx'
|
||||
].forEach(p => {
|
||||
assert.ok(Object.prototype.hasOwnProperty.call(result, p), `copies property ${p}`);
|
||||
@@ -21,8 +23,17 @@ module('Unit | Utility | process-contribution-data', function() {
|
||||
});
|
||||
|
||||
test('does not copy unnecessary properties', function(assert) {
|
||||
const result = processContributionData(testData);
|
||||
|
||||
['exists', '5'].forEach(p => {
|
||||
assert.notOk(Object.prototype.hasOwnProperty.call(result, p));
|
||||
})
|
||||
});
|
||||
|
||||
test('includeDetails option', function(assert) {
|
||||
const result = processContributionData(testData, { includeDetails: true });
|
||||
|
||||
assert.ok(Object.prototype.hasOwnProperty.call(result, 'details'), 'includes the details property/value');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user