mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 10:24:39 +08:00
missing prettified files
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { acceptance } from "helpers/qunit-helpers";
|
||||
import { clearPopupMenuOptionsCallback } from "discourse/controllers/composer";
|
||||
|
||||
acceptance('Details Button', {
|
||||
acceptance("Details Button", {
|
||||
loggedIn: true,
|
||||
beforeEach: function() {
|
||||
clearPopupMenuOptionsCallback();
|
||||
@ -12,23 +12,25 @@ function findTextarea() {
|
||||
return find(".d-editor-input")[0];
|
||||
}
|
||||
|
||||
test('details button', (assert) => {
|
||||
const popupMenu = selectKit('.toolbar-popup-menu-options');
|
||||
test("details button", assert => {
|
||||
const popupMenu = selectKit(".toolbar-popup-menu-options");
|
||||
|
||||
visit("/");
|
||||
click('#create-topic');
|
||||
click("#create-topic");
|
||||
|
||||
popupMenu.expand().selectRowByValue('insertDetails');
|
||||
popupMenu.expand().selectRowByValue("insertDetails");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find(".d-editor-input").val(),
|
||||
`\n[details="${I18n.t("composer.details_title")}"]\n${I18n.t("composer.details_text")}\n[/details]\n`,
|
||||
'it should contain the right output'
|
||||
`\n[details="${I18n.t("composer.details_title")}"]\n${I18n.t(
|
||||
"composer.details_text"
|
||||
)}\n[/details]\n`,
|
||||
"it should contain the right output"
|
||||
);
|
||||
});
|
||||
|
||||
fillIn('.d-editor-input', "This is my title");
|
||||
fillIn(".d-editor-input", "This is my title");
|
||||
|
||||
andThen(() => {
|
||||
const textarea = findTextarea();
|
||||
@ -36,21 +38,31 @@ test('details button', (assert) => {
|
||||
textarea.selectionEnd = textarea.value.length;
|
||||
});
|
||||
|
||||
popupMenu.expand().selectRowByValue('insertDetails');
|
||||
popupMenu.expand().selectRowByValue("insertDetails");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find(".d-editor-input").val(),
|
||||
`\n[details="${I18n.t("composer.details_title")}"]\nThis is my title\n[/details]\n`,
|
||||
'it should contain the right selected output'
|
||||
`\n[details="${I18n.t(
|
||||
"composer.details_title"
|
||||
)}"]\nThis is my title\n[/details]\n`,
|
||||
"it should contain the right selected output"
|
||||
);
|
||||
|
||||
const textarea = findTextarea();
|
||||
assert.equal(textarea.selectionStart, 21, 'it should start highlighting at the right position');
|
||||
assert.equal(textarea.selectionEnd, 37, 'it should end highlighting at the right position');
|
||||
assert.equal(
|
||||
textarea.selectionStart,
|
||||
21,
|
||||
"it should start highlighting at the right position"
|
||||
);
|
||||
assert.equal(
|
||||
textarea.selectionEnd,
|
||||
37,
|
||||
"it should end highlighting at the right position"
|
||||
);
|
||||
});
|
||||
|
||||
fillIn('.d-editor-input', "Before some text in between After");
|
||||
fillIn(".d-editor-input", "Before some text in between After");
|
||||
|
||||
andThen(() => {
|
||||
const textarea = findTextarea();
|
||||
@ -58,21 +70,31 @@ test('details button', (assert) => {
|
||||
textarea.selectionEnd = 28;
|
||||
});
|
||||
|
||||
popupMenu.expand().selectRowByValue('insertDetails');
|
||||
popupMenu.expand().selectRowByValue("insertDetails");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find(".d-editor-input").val(),
|
||||
`Before \n[details="${I18n.t("composer.details_title")}"]\nsome text in between\n[/details]\n After`,
|
||||
'it should contain the right output'
|
||||
`Before \n[details="${I18n.t(
|
||||
"composer.details_title"
|
||||
)}"]\nsome text in between\n[/details]\n After`,
|
||||
"it should contain the right output"
|
||||
);
|
||||
|
||||
const textarea = findTextarea();
|
||||
assert.equal(textarea.selectionStart, 28, 'it should start highlighting at the right position');
|
||||
assert.equal(textarea.selectionEnd, 48, 'it should end highlighting at the right position');
|
||||
assert.equal(
|
||||
textarea.selectionStart,
|
||||
28,
|
||||
"it should start highlighting at the right position"
|
||||
);
|
||||
assert.equal(
|
||||
textarea.selectionEnd,
|
||||
48,
|
||||
"it should end highlighting at the right position"
|
||||
);
|
||||
});
|
||||
|
||||
fillIn('.d-editor-input', "Before \nsome text in between\n After");
|
||||
fillIn(".d-editor-input", "Before \nsome text in between\n After");
|
||||
|
||||
andThen(() => {
|
||||
const textarea = findTextarea();
|
||||
@ -80,28 +102,38 @@ test('details button', (assert) => {
|
||||
textarea.selectionEnd = 29;
|
||||
});
|
||||
|
||||
popupMenu.expand().selectRowByValue('insertDetails');
|
||||
popupMenu.expand().selectRowByValue("insertDetails");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find(".d-editor-input").val(),
|
||||
`Before \n\n[details="${I18n.t("composer.details_title")}"]\nsome text in between\n[/details]\n\n After`,
|
||||
'it should contain the right output'
|
||||
`Before \n\n[details="${I18n.t(
|
||||
"composer.details_title"
|
||||
)}"]\nsome text in between\n[/details]\n\n After`,
|
||||
"it should contain the right output"
|
||||
);
|
||||
|
||||
const textarea = findTextarea();
|
||||
assert.equal(textarea.selectionStart, 29, 'it should start highlighting at the right position');
|
||||
assert.equal(textarea.selectionEnd, 49, 'it should end highlighting at the right position');
|
||||
assert.equal(
|
||||
textarea.selectionStart,
|
||||
29,
|
||||
"it should start highlighting at the right position"
|
||||
);
|
||||
assert.equal(
|
||||
textarea.selectionEnd,
|
||||
49,
|
||||
"it should end highlighting at the right position"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('details button surrounds all selected text in a single details block', (assert) => {
|
||||
const multilineInput = 'first line\n\nsecond line\n\nthird line';
|
||||
const popupMenu = selectKit('.toolbar-popup-menu-options');
|
||||
test("details button surrounds all selected text in a single details block", assert => {
|
||||
const multilineInput = "first line\n\nsecond line\n\nthird line";
|
||||
const popupMenu = selectKit(".toolbar-popup-menu-options");
|
||||
|
||||
visit("/");
|
||||
click('#create-topic');
|
||||
fillIn('.d-editor-input', multilineInput);
|
||||
click("#create-topic");
|
||||
fillIn(".d-editor-input", multilineInput);
|
||||
|
||||
andThen(() => {
|
||||
const textarea = findTextarea();
|
||||
@ -109,13 +141,15 @@ test('details button surrounds all selected text in a single details block', (as
|
||||
textarea.selectionEnd = textarea.value.length;
|
||||
});
|
||||
|
||||
popupMenu.expand().selectRowByValue('insertDetails');
|
||||
popupMenu.expand().selectRowByValue("insertDetails");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find(".d-editor-input").val(),
|
||||
`\n[details="${I18n.t('composer.details_title')}"]\n${multilineInput}\n[/details]\n`,
|
||||
'it should contain the right output'
|
||||
`\n[details="${I18n.t(
|
||||
"composer.details_title"
|
||||
)}"]\n${multilineInput}\n[/details]\n`,
|
||||
"it should contain the right output"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,31 +1,38 @@
|
||||
import { default as PrettyText, buildOptions } from 'pretty-text/pretty-text';
|
||||
import { default as PrettyText, buildOptions } from "pretty-text/pretty-text";
|
||||
|
||||
QUnit.module("lib:details-cooked-test");
|
||||
|
||||
const defaultOpts = buildOptions({
|
||||
siteSettings: {
|
||||
enable_emoji: true,
|
||||
emoji_set: 'emoji_one',
|
||||
highlighted_languages: 'json|ruby|javascript',
|
||||
default_code_lang: 'auto',
|
||||
emoji_set: "emoji_one",
|
||||
highlighted_languages: "json|ruby|javascript",
|
||||
default_code_lang: "auto"
|
||||
},
|
||||
censoredWords: 'shucks|whiz|whizzer',
|
||||
censoredWords: "shucks|whiz|whizzer",
|
||||
getURL: url => url
|
||||
});
|
||||
|
||||
|
||||
test("details", assert => {
|
||||
const cooked = (input, expected, text) => {
|
||||
assert.equal(new PrettyText(defaultOpts).cook(input), expected.replace(/\/>/g, ">"), text);
|
||||
assert.equal(
|
||||
new PrettyText(defaultOpts).cook(input),
|
||||
expected.replace(/\/>/g, ">"),
|
||||
text
|
||||
);
|
||||
};
|
||||
cooked(`<details><summary>Info</summary>coucou</details>`,
|
||||
`<details><summary>Info</summary>coucou</details>`,
|
||||
"manual HTML for details");
|
||||
cooked(
|
||||
`<details><summary>Info</summary>coucou</details>`,
|
||||
`<details><summary>Info</summary>coucou</details>`,
|
||||
"manual HTML for details"
|
||||
);
|
||||
|
||||
cooked("[details=testing]\ntest\n[/details]",
|
||||
`<details>
|
||||
cooked(
|
||||
"[details=testing]\ntest\n[/details]",
|
||||
`<details>
|
||||
<summary>
|
||||
testing</summary>
|
||||
<p>test</p>
|
||||
</details>`);
|
||||
</details>`
|
||||
);
|
||||
});
|
||||
|
Reference in New Issue
Block a user