REFACTOR: Use imports for Ember.run

This commit is contained in:
Robin Ward
2019-10-29 14:52:36 -04:00
parent c7475ee03b
commit 5ca60fcb6b
151 changed files with 485 additions and 270 deletions

View File

@@ -1,3 +1,4 @@
import { run } from "@ember/runloop";
import selectKit from "helpers/select-kit-helper";
import { acceptance } from "helpers/qunit-helpers";
import { toggleCheckDraftPopup } from "discourse/controllers/composer";
@@ -84,7 +85,7 @@ QUnit.test("Tests the Composer controls", async assert => {
event[mac ? "metaKey" : "ctrlKey"] = true;
event.keyCode = 66;
Ember.run(() => textarea.dispatchEvent(event));
run(() => textarea.dispatchEvent(event));
const example = I18n.t(`composer.bold_text`);
assert.equal(

View File

@@ -1,3 +1,4 @@
import { run } from "@ember/runloop";
import { acceptance, controllerFor } from "helpers/qunit-helpers";
import showModal from "discourse/lib/show-modal";
@@ -37,7 +38,7 @@ QUnit.test("modal", async function(assert) {
'{{#d-modal-body title="" class="" dismissable=false}}test{{/d-modal-body}}'
);
Ember.run(() => showModal("not-dismissable", {}));
run(() => showModal("not-dismissable", {}));
assert.ok(find(".d-modal:visible").length === 1, "modal should appear");

View File

@@ -1,3 +1,4 @@
import { next } from "@ember/runloop";
import componentTest from "helpers/component-test";
import { withPluginApi } from "discourse/lib/plugin-api";
import formatTextWithSelection from "helpers/d-editor-helper";
@@ -747,7 +748,7 @@ composerTestCase("replace-text event for composer", async function(assert) {
.lookup("service:app-events")
.trigger("composer:replace-text", "green", "yellow", { forceFocus: true });
Ember.run.next(() => {
next(() => {
let expect = formatTextWithSelection(AFTER, CASE.after);
let actual = formatTextWithSelection(
this.value,

View File

@@ -1,4 +1,5 @@
import EmberObject from "@ember/object";
import { next } from "@ember/runloop";
import Topic from "discourse/models/topic";
import PostStream from "discourse/models/post-stream";
import { Placeholder } from "discourse/lib/posts-with-placeholders";
@@ -545,7 +546,7 @@ QUnit.test(
const done = assert.async();
controller.send("deletePost", post);
Ember.run.next(() => {
next(() => {
assert.ok(destroyed, "post was destroyed");
done();
});

View File

@@ -1,3 +1,5 @@
import { run } from "@ember/runloop";
import { later } from "@ember/runloop";
/* global QUnit, resetSite */
import sessionFixtures from "fixtures/session-fixtures";
@@ -155,7 +157,7 @@ export function controllerFor(controller, model) {
export function asyncTestDiscourse(text, func) {
QUnit.test(text, function(assert) {
const done = assert.async();
Ember.run(() => {
run(() => {
func.call(this, assert);
done();
});
@@ -206,7 +208,7 @@ export function waitFor(assert, callback, timeout) {
timeout = timeout || 500;
const done = assert.async();
Ember.run.later(() => {
later(() => {
callback();
done();
}, timeout);

View File

@@ -1,3 +1,4 @@
import { later } from "@ember/runloop";
import DiscourseURL from "discourse/lib/url";
import ClickTrack from "discourse/lib/click-track";
import { fixture, logIn } from "helpers/qunit-helpers";
@@ -173,7 +174,7 @@ QUnit.skip("restores the href after a while", async assert => {
assert.timeout(75);
const done = assert.async();
Ember.run.later(() => {
later(() => {
assert.equal(fixture("a").attr("href"), "http://www.google.com");
done();
});

View File

@@ -1,8 +1,9 @@
import { run } from "@ember/runloop";
import createStore from "helpers/create-store";
QUnit.module("Discourse.NavItem", {
beforeEach() {
Ember.run(function() {
run(function() {
const asianCategory = Discourse.Category.create({
name: "确实是这样",
id: 343434

View File

@@ -1,3 +1,4 @@
import { next } from "@ember/runloop";
import { moduleForWidget, widgetTest } from "helpers/widget-test";
import { createWidget } from "discourse/widgets/widget";
import { withPluginApi } from "discourse/lib/plugin-api";
@@ -159,7 +160,7 @@ widgetTest("widget update with promise", {
click() {
return new Ember.RSVP.Promise(resolve => {
Ember.run.next(() => {
next(() => {
this.state.name = "Robin";
resolve();
});