Commit 4fa4bff8 authored by Zack Cuddy's avatar Zack Cuddy

Changes based on @ekigbo feedback

Mock data for readible tests.
Use filterByDataType method.
parent 65ec1f17
...@@ -31,25 +31,22 @@ export default { ...@@ -31,25 +31,22 @@ export default {
return [ return [
{ {
title: this.$options.i18n.git, title: this.$options.i18n.git,
sync: syncInfoData sync: this.filterByDataType(syncInfoData, REPOSITORY),
.filter((replicable) => replicable.dataType === REPOSITORY) verification: this.filterByDataType(verificationInfoData, REPOSITORY),
.map((d) => d.values),
verification: verificationInfoData
.filter((replicable) => replicable.dataType === REPOSITORY)
.map((d) => d.values),
}, },
{ {
title: this.$options.i18n.file, title: this.$options.i18n.file,
sync: syncInfoData sync: this.filterByDataType(syncInfoData, BLOB),
.filter((replicable) => replicable.dataType === BLOB) verification: this.filterByDataType(verificationInfoData, BLOB),
.map((d) => d.values),
verification: verificationInfoData
.filter((replicable) => replicable.dataType === BLOB)
.map((d) => d.values),
}, },
]; ];
}, },
}, },
methods: {
filterByDataType(data, type) {
return data.filter((replicable) => replicable.dataType === type).map((d) => d.values);
},
},
}; };
</script> </script>
......
...@@ -66,12 +66,28 @@ describe('GeoNodeReplicationCounts', () => { ...@@ -66,12 +66,28 @@ describe('GeoNodeReplicationCounts', () => {
}); });
}); });
const mockRepositoryData = { dataType: REPOSITORY, values: { total: 100, success: 0 } };
const mockBlobData = { dataType: BLOB, values: { total: 100, success: 100 } };
const mockGitEmptySync = { title: 'Git', sync: [], verification: [] };
const mockGitSuccess0 = {
title: 'Git',
sync: [{ total: 100, success: 0 }],
verification: [{ total: 100, success: 0 }],
};
const mockFileEmptySync = { title: 'File', sync: [], verification: [] };
const mockFileSync100 = {
title: 'File',
sync: [{ total: 100, success: 100 }],
verification: [{ total: 100, success: 100 }],
};
describe.each` describe.each`
description | mockGetterData | expectedData description | mockGetterData | expectedData
${'with no data'} | ${[]} | ${[{ title: 'Git', sync: [], verification: [] }, { title: 'File', sync: [], verification: [] }]} ${'with no data'} | ${[]} | ${[mockGitEmptySync, mockFileEmptySync]}
${'with no File data'} | ${[{ dataType: REPOSITORY, values: { total: 100, success: 0 } }]} | ${[{ title: 'Git', sync: [{ total: 100, success: 0 }], verification: [{ total: 100, success: 0 }] }, { title: 'File', sync: [], verification: [] }]} ${'with no File data'} | ${[mockRepositoryData]} | ${[mockGitSuccess0, mockFileEmptySync]}
${'with no Git data'} | ${[{ dataType: BLOB, values: { total: 100, success: 100 } }]} | ${[{ title: 'Git', sync: [], verification: [] }, { title: 'File', sync: [{ total: 100, success: 100 }], verification: [{ total: 100, success: 100 }] }]} ${'with no Git data'} | ${[mockBlobData]} | ${[mockGitEmptySync, mockFileSync100]}
${'with all data'} | ${[{ dataType: REPOSITORY, values: { total: 100, success: 0 } }, { dataType: BLOB, values: { total: 100, success: 100 } }]} | ${[{ title: 'Git', sync: [{ total: 100, success: 0 }], verification: [{ total: 100, success: 0 }] }, { title: 'File', sync: [{ total: 100, success: 100 }], verification: [{ total: 100, success: 100 }] }]} ${'with all data'} | ${[mockRepositoryData, mockBlobData]} | ${[mockGitSuccess0, mockFileSync100]}
`('replicationOverview $description', ({ mockGetterData, expectedData }) => { `('replicationOverview $description', ({ mockGetterData, expectedData }) => {
beforeEach(() => { beforeEach(() => {
createComponent(null, { createComponent(null, {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment