refactoring

This commit is contained in:
frankknoll
2023-11-10 08:44:21 +01:00
parent 2456317257
commit 998c55f50e
6 changed files with 84 additions and 78 deletions

View File

@@ -0,0 +1,52 @@
QUnit.module('DictUtilsTest', function () {
QUnit.test.each(
'shouldRetainCommonKeys',
[
[
{
dict1: {
"lotX": 1.0
},
dict2: {
"lotY": 2.0
}
},
{
dict1: {
},
dict2: {
}
}
],
[
{
dict1: {
"lotX": 1.0,
"lotCommon": 2.0
},
dict2: {
"lotCommon": 3.0,
"lotY": 4.0
}
},
{
dict1: {
"lotCommon": 2.0
},
dict2: {
"lotCommon": 3.0
}
}
]
],
(assert, [dicts, dictsHavingCommonKeys]) => {
// Given
// When
const dictsHavingCommonKeysActual = DictUtils.retainCommonKeys(dicts);
// Then
assert.deepEqual(dictsHavingCommonKeysActual, dictsHavingCommonKeys);
});
});

View File

@@ -1,55 +1,5 @@
QUnit.module('SymptomVsSymptomChartDataProviderTest', function () {
QUnit.test.each(
'shouldRetainCommonLots',
[
[
{
dict1: {
"lotX": 1.0
},
dict2: {
"lotY": 2.0
}
},
{
dict1: {
},
dict2: {
}
}
],
[
{
dict1: {
"lotX": 1.0,
"lotCommon": 2.0
},
dict2: {
"lotCommon": 3.0,
"lotY": 4.0
}
},
{
dict1: {
"lotCommon": 2.0
},
dict2: {
"lotCommon": 3.0
}
}
]
],
(assert, [dicts, dictsHavingCommonKeys]) => {
// Given
// When
const dictsHavingCommonKeysActual = SymptomVsSymptomChartDataProvider.retainCommonKeys(dicts);
// Then
assert.deepEqual(dictsHavingCommonKeysActual, dictsHavingCommonKeys);
});
QUnit.test('shouldProvideChartData', function (assert) {
// Given
const prrByLotX = {

View File

@@ -19,6 +19,7 @@
<script src="../js/SymptomVsSymptomChartView.js"></script>
<script src="../js/SymptomVsSymptomChartDataProvider.js"></script>
<script src="../js/SymptomVsSymptomChartViewInitializer.js"></script>
<script src="../js/DictUtils.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.17.2.css">
<script src="https://code.jquery.com/qunit/qunit-2.17.2.js"></script>
<script type="text/javascript" src="./jshamcrest.js"></script>
@@ -28,6 +29,7 @@
JsMockito.Integration.QUnit();
</script>
<script src="./SymptomVsSymptomChartDataProviderTest.js"></script>
<script src="./DictUtilsTest.js"></script>
</head>
<body>