DEV: Abstract `Ember.testing` so our application code doesn't use it

This commit is contained in:
Robin Ward 2020-05-29 12:16:05 -04:00
parent e159fb06df
commit 3fe5eacd1b
4 changed files with 16 additions and 8 deletions

View File

@ -1,3 +1,9 @@
export const INPUT_DELAY = 250;
export default { environment: Ember.testing ? "test" : "development" };
let environment = Ember.testing ? "test" : "development";
export function isTesting() {
return environment === "test";
}
export default { environment };

View File

@ -1,7 +1,7 @@
import Ember from "ember";
import { isTesting } from "discourse-common/config/environment";
export function reload() {
if (!Ember.testing) {
if (!isTesting()) {
location.reload();
}
}

View File

@ -5,10 +5,11 @@ import { TAG_HASHTAG_POSTFIX } from "discourse/lib/tag-hashtags";
import { SEPARATOR } from "discourse/lib/category-hashtags";
import { Promise } from "rsvp";
import { later, cancel } from "@ember/runloop";
import { isTesting } from "discourse-common/config/environment";
var cache = {};
var cacheTime;
var oldSearch;
let cache = {};
let cacheTime;
let oldSearch;
function updateCache(term, results) {
cache[term] = results;
@ -22,7 +23,7 @@ function searchTags(term, categories, limit) {
() => {
resolve(CANCELLED_STATUS);
},
Ember.testing ? 50 : 5000
isTesting() ? 50 : 5000
);
const debouncedSearch = discourseDebounce((q, cats, resultFunc) => {

View File

@ -4,6 +4,7 @@ import { userPath } from "discourse/lib/url";
import { emailValid } from "discourse/lib/utilities";
import { Promise } from "rsvp";
import { later, cancel } from "@ember/runloop";
import { isTesting } from "discourse-common/config/environment";
var cache = {},
cacheKey,
@ -185,7 +186,7 @@ export default function userSearch(options) {
() => {
resolve(CANCELLED_STATUS);
},
Ember.testing ? 50 : 5000
isTesting() ? 50 : 5000
);
if (skipSearch(term, options.allowEmails)) {