DEV: Use qunit-dom's hasValue wherever possible (#30018)

This commit is contained in:
Jarek Radosz
2024-12-01 20:37:24 +01:00
committed by GitHub
parent efa2589204
commit 6e4baaf092
31 changed files with 473 additions and 545 deletions

View File

@ -2,7 +2,7 @@ import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import { i18n } from 'discourse-i18n';
import { i18n } from "discourse-i18n";
acceptance("Details Button", function (needs) {
needs.user();
@ -19,13 +19,14 @@ acceptance("Details Button", function (needs) {
await popupMenu.expand();
await popupMenu.selectRowByName(i18n("details.title"));
assert.strictEqual(
query(".d-editor-input").value,
`\n[details="${i18n("composer.details_title")}"]\n${i18n(
"composer.details_text"
)}\n[/details]\n`,
"it should contain the right output"
);
assert
.dom(".d-editor-input")
.hasValue(
`\n[details="${i18n("composer.details_title")}"]\n${i18n(
"composer.details_text"
)}\n[/details]\n`,
"contains the right output"
);
await fillIn(".d-editor-input", "This is my title");
@ -36,13 +37,14 @@ acceptance("Details Button", function (needs) {
await popupMenu.expand();
await popupMenu.selectRowByName(i18n("details.title"));
assert.strictEqual(
query(".d-editor-input").value,
`\n[details="${i18n(
"composer.details_title"
)}"]\nThis is my title\n[/details]\n`,
"it should contain the right selected output"
);
assert
.dom(".d-editor-input")
.hasValue(
`\n[details="${i18n(
"composer.details_title"
)}"]\nThis is my title\n[/details]\n`,
"contains the right selected output"
);
assert.strictEqual(
textarea.selectionStart,
@ -63,13 +65,14 @@ acceptance("Details Button", function (needs) {
await popupMenu.expand();
await popupMenu.selectRowByName(i18n("details.title"));
assert.strictEqual(
query(".d-editor-input").value,
`Before \n[details="${i18n(
"composer.details_title"
)}"]\nsome text in between\n[/details]\n After`,
"it should contain the right output"
);
assert
.dom(".d-editor-input")
.hasValue(
`Before \n[details="${i18n(
"composer.details_title"
)}"]\nsome text in between\n[/details]\n After`,
"contains the right output"
);
assert.strictEqual(
textarea.selectionStart,
@ -90,13 +93,14 @@ acceptance("Details Button", function (needs) {
await popupMenu.expand();
await popupMenu.selectRowByName(i18n("details.title"));
assert.strictEqual(
query(".d-editor-input").value,
`Before \n\n[details="${i18n(
"composer.details_title"
)}"]\nsome text in between\n[/details]\n\n After`,
"it should contain the right output"
);
assert
.dom(".d-editor-input")
.hasValue(
`Before \n\n[details="${i18n(
"composer.details_title"
)}"]\nsome text in between\n[/details]\n\n After`,
"contains the right output"
);
assert.strictEqual(
textarea.selectionStart,
@ -128,12 +132,13 @@ acceptance("Details Button", function (needs) {
await popupMenu.expand();
await popupMenu.selectRowByName(i18n("details.title"));
assert.strictEqual(
query(".d-editor-input").value,
`\n[details="${i18n(
"composer.details_title"
)}"]\n${multilineInput}\n[/details]\n`,
"it should contain the right output"
);
assert
.dom(".d-editor-input")
.hasValue(
`\n[details="${i18n(
"composer.details_title"
)}"]\n${multilineInput}\n[/details]\n`,
"contains the right output"
);
});
});