refining SymptomVsSymptomChartDataProviderTest
This commit is contained in:
@@ -1,13 +1,31 @@
|
||||
class SymptomVsSymptomChartDataProvider {
|
||||
|
||||
static retainCommonLots({ prrByLotX, prrByLotY }) {
|
||||
const commonLots = SymptomVsSymptomChartDataProvider.#getCommonKeys(prrByLotX, prrByLotY);
|
||||
// FK-TODO: extract utility class and test
|
||||
static retainCommonKeys({ dict1, dict2 }) {
|
||||
const commonKeys = SymptomVsSymptomChartDataProvider.#getCommonKeys(dict1, dict2);
|
||||
return {
|
||||
prrByLotX: SymptomVsSymptomChartDataProvider.#retainKeysOfDict(prrByLotX, commonLots),
|
||||
prrByLotY: SymptomVsSymptomChartDataProvider.#retainKeysOfDict(prrByLotY, commonLots)
|
||||
dict1: SymptomVsSymptomChartDataProvider.#retainKeysOfDict(dict1, commonKeys),
|
||||
dict2: SymptomVsSymptomChartDataProvider.#retainKeysOfDict(dict2, commonKeys)
|
||||
};
|
||||
}
|
||||
|
||||
static getChartData({ prrByLotX, prrByLotY }) {
|
||||
const { dict1: prrByLotXCommon, dict2: prrByLotYCommon } =
|
||||
SymptomVsSymptomChartDataProvider.retainCommonKeys(
|
||||
{
|
||||
dict1: prrByLotX,
|
||||
dict2: prrByLotY
|
||||
});
|
||||
return Object
|
||||
.keys(prrByLotXCommon)
|
||||
.map(
|
||||
lot =>
|
||||
({
|
||||
x: prrByLotXCommon[lot],
|
||||
y: prrByLotYCommon[lot]
|
||||
}));
|
||||
}
|
||||
|
||||
static #getCommonKeys(dict1, dict2) {
|
||||
return Sets.intersection(
|
||||
SymptomVsSymptomChartDataProvider.#getKeySet(dict1),
|
||||
|
||||
@@ -5,48 +5,73 @@ QUnit.module('SymptomVsSymptomChartDataProviderTest', function () {
|
||||
[
|
||||
[
|
||||
{
|
||||
prrByLotX: {
|
||||
dict1: {
|
||||
"lotX": 1.0
|
||||
},
|
||||
prrByLotY: {
|
||||
dict2: {
|
||||
"lotY": 2.0
|
||||
}
|
||||
},
|
||||
{
|
||||
prrByLotX: {
|
||||
dict1: {
|
||||
},
|
||||
prrByLotY: {
|
||||
dict2: {
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
prrByLotX: {
|
||||
dict1: {
|
||||
"lotX": 1.0,
|
||||
"lotCommon": 2.0
|
||||
},
|
||||
prrByLotY: {
|
||||
dict2: {
|
||||
"lotCommon": 3.0,
|
||||
"lotY": 4.0
|
||||
}
|
||||
},
|
||||
{
|
||||
prrByLotX: {
|
||||
dict1: {
|
||||
"lotCommon": 2.0
|
||||
},
|
||||
prrByLotY: {
|
||||
dict2: {
|
||||
"lotCommon": 3.0
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
(assert, [dataSets, mergedDataSets]) => {
|
||||
(assert, [dicts, dictsHavingCommonKeys]) => {
|
||||
// Given
|
||||
|
||||
// When
|
||||
const mergedDataSetsActual = SymptomVsSymptomChartDataProvider.retainCommonLots(dataSets);
|
||||
const dictsHavingCommonKeysActual = SymptomVsSymptomChartDataProvider.retainCommonKeys(dicts);
|
||||
|
||||
// Then
|
||||
assert.deepEqual(mergedDataSetsActual, mergedDataSets);
|
||||
assert.deepEqual(dictsHavingCommonKeysActual, dictsHavingCommonKeys);
|
||||
});
|
||||
|
||||
QUnit.test('shouldProvideChartData', function (assert) {
|
||||
// Given
|
||||
const prrByLotX = {
|
||||
"lotX": 1.0,
|
||||
"lotCommon": 2.0
|
||||
};
|
||||
const prrByLotY = {
|
||||
"lotCommon": 3.0,
|
||||
"lotY": 4.0
|
||||
};
|
||||
|
||||
// When
|
||||
const chartData = SymptomVsSymptomChartDataProvider.getChartData({ prrByLotX, prrByLotY });
|
||||
|
||||
// Then
|
||||
assert.deepEqual(
|
||||
chartData,
|
||||
[
|
||||
{
|
||||
x: 2.0,
|
||||
y: 3.0
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user