This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/acceptance/admin-emails-test.js
Robin Ward 71d37953d5 REFACTOR: Import QUnit and related helpers rather than globals
We used many global functions to handle tests when they should be
imported like other libraries in our application. This also gets us
closer to the way Ember CLI prefers our tests to be laid out.
2020-10-07 11:50:49 -04:00

43 lines
1.1 KiB
JavaScript

import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import pretender from "discourse/tests/helpers/create-pretender";
acceptance("Admin - Emails", { loggedIn: true });
const email = `
From: "somebody" <somebody@example.com>
To: someone@example.com
Date: Mon, 3 Dec 2018 00:00:00 -0000
Subject: This is some subject
Content-Type: text/plain; charset="UTF-8"
Hello, this is a test!
---
This part should be elided.`.trim();
test("shows selected and elided text", async (assert) => {
pretender.post("/admin/email/advanced-test", () => {
return [
200,
{ "Content-Type": "application/json" },
{
format: 1,
text: "Hello, this is a test!",
elided: "---\n\nThis part should be elided.",
},
];
});
await visit("/admin/email/advanced-test");
await fillIn("textarea.email-body", email);
await click(".email-advanced-test button");
assert.equal(find(".text pre").text(), "Hello, this is a test!");
assert.equal(
find(".elided pre").text(),
"---\n\nThis part should be elided."
);
});