0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-27 03:20:27 +01:00
discourse-custom-wizard/assets/javascripts/wizard/tests/helpers/acceptance.js.es6

54 Zeilen
1,2 KiB
Text

2022-03-16 12:33:34 +01:00
import { module } from "qunit";
import setupPretender, { response } from "../pretender";
import startApp from "../helpers/start-app";
let server;
let app;
function acceptance(name, requests, cb) {
2022-06-15 08:59:09 +02:00
module(`Acceptance: ${name}`, function (hooks) {
hooks.beforeEach(function () {
server = setupPretender(function (pretender) {
requests.forEach((req) => {
pretender[req.verb](req.path, () =>
response(req.status, req.response)
);
2022-03-16 12:33:34 +01:00
});
return pretender;
});
app = startApp();
});
2022-06-15 08:59:09 +02:00
hooks.afterEach(function () {
2022-03-16 12:33:34 +01:00
app.destroy();
server.shutdown();
});
cb(hooks);
});
}
export default acceptance;
2022-06-15 08:59:09 +02:00
export { server };
2022-03-16 12:33:34 +01:00
// The discourse/test/helpers/qunit-helpers file has many functions and imports
// we don't need, so there will be some duplciation here.
export function queryAll(selector, context) {
context = context || "#ember-testing";
return $(selector, context);
}
export function query() {
return document.querySelector("#ember-testing").querySelector(...arguments);
}
export function visible(selector) {
return queryAll(selector + ":visible").length > 0;
}
export function count(selector) {
return queryAll(selector).length;
}