Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function visit(url: string) {
try {
await _visit(url);
} catch (e) {
if (e.message !== 'TransitionAborted') {
throw e;
}
// Set this.element for application tests as the original
// visit's attempt to do so was interupted by an exception
const context: any = getContext();
context.element = document.querySelector('#ember-testing');
}
await settled();
}
export default async function visitAddon(addon) {
return visit(`/addons/${addon.name}`);
}
test('visiting /bar', async function(assert) {
await visit('/bar');
assert.equal(currentURL(), '/bar');
});
test('visiting /foo', async function(assert) {
await visit('/foo');
assert.equal(currentURL(), '/foo');
});
test('visiting /foo', async function(assert) {
await visit('/foo');
await click('#bar');
await click(findAll('.baz a')[12]);
assert.equal(currentURL(), '/foo');
});
test('visiting /foo', async function(assert) {
await visit('/foo');
assert.ok(true);
});
test('visiting /foo', async function(assert) {
await visit('/foo');
assert.equal(currentURL(), '/foo');
assert.equal(currentPath(), 'foo.index');
assert.equal(currentRouteName(), 'foo');
});
export async function createCards(args) {
for (let id of Object.keys(args)) {
await visit('/cards/new');
await setCardId(id);
for (let [index, [name, type, neededWhenEmbedded]] of args[id].entries()) {
await addField(name, type, neededWhenEmbedded, index);
}
await click('[data-test-card-save-btn]');
await waitFor(`[data-test-card-schema="${id}"]`, { timeout });
await visit(`/cards/${id}/edit`);
for (let [name, , , value] of args[id]) {
if (value == null) {
continue;
}
await setFieldValue(name, value);
}
await saveCard('editor', id);
await visit(`/cards/${id}`);
test('routing helpers', async (assert) => {
await visit('/foo');
assert.equal(currentURL(), '/foo');
assert.equal(currentRouteName(), 'foo');
});
function visit(...args) {
return require('@ember/test-helpers').visit(...args);
}