diff.mjs: Fixes tests and adds default flag
* Sets default flag to `false` for `showSubtraction` flag. * Removes extra span for else case that was causing some tests to fail. Moreover, the previous behavior was defined as that. * Adds custom test for the showSubtraction option, both using the `showAdded` and `showRemoved` flags.
This commit is contained in:
parent
726e117656
commit
9108b3923b
@ -50,7 +50,7 @@ class Diff extends Operation {
|
|||||||
{
|
{
|
||||||
"name": "Show subtraction",
|
"name": "Show subtraction",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"value": true
|
"value": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Ignore whitespace",
|
"name": "Ignore whitespace",
|
||||||
@ -123,7 +123,7 @@ class Diff extends Operation {
|
|||||||
} else if (diff[i].removed) {
|
} else if (diff[i].removed) {
|
||||||
if (showRemoved) output += "<span class='hl3'>" + Utils.escapeHtml(diff[i].value) + "</span>";
|
if (showRemoved) output += "<span class='hl3'>" + Utils.escapeHtml(diff[i].value) + "</span>";
|
||||||
} else if (!showSubtraction) {
|
} else if (!showSubtraction) {
|
||||||
output += Utils.escapeHtml(diff[i].value) + "</span>";
|
output += Utils.escapeHtml(diff[i].value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,29 @@ TestRegister.addTests([
|
|||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
"op": "Diff",
|
"op": "Diff",
|
||||||
"args": ["\\n\\n", "Character", true, true, false]
|
"args": ["\\n\\n", "Character", true, true, false, false]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Diff added with subtraction, basic usage",
|
||||||
|
input: "testing23\n\ntesting123",
|
||||||
|
expectedOutput: "<span class='hl5'>1</span>",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Diff",
|
||||||
|
"args": ["\\n\\n", "Character", true, true, true, false]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Diff removed with subtraction, basic usage",
|
||||||
|
input: "testing123\n\ntesting3",
|
||||||
|
expectedOutput: "<span class='hl3'>12</span>",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Diff",
|
||||||
|
"args": ["\\n\\n", "Character", true, true, true, false]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user