Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test(':selected is replaced correctly', function(assert) {
// find
const checkedVal = find('.foo input:checked').value;
assert.equal(checkedVal, 13);
// findAll
const checkedCount = findAll('select option:checked').length;
assert.equal(checkedCount, 3);
// Multiple jQuery selectors
const firstChecked = find('.foo input:checked').value;
const secondChecked = find(findAll('.foo input:checked')[2]).value;
});
test(':selected is replaced correctly', function(assert) {
// find
const checkedVal = find('.foo input:checked').value;
assert.equal(checkedVal, 13);
// findAll
const checkedCount = findAll('select option:checked').length;
assert.equal(checkedCount, 3);
});
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 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();
}
}
// this is used to ensure that the testing container is always reset properly
let testElementContainer = document.getElementById('ember-testing-container');
let actual = testElementContainer.innerHTML;
let expected = `<div id="ember-testing"></div>`;
if (actual !== expected) {
let message = `Expected #ember-testing-container to be reset after ${module}: ${name}, but was \`${actual}\``;
cleanupFailures.push(message);
// eslint-disable-next-line
console.error(message);
testElementContainer.innerHTML = expected;
}
if (!isSettled()) {
let message = `Expected to be settled after ${module}: ${name}, but was \`${JSON.stringify(
getSettledState()
)}\``;
asyncLeakageFailures.push(message);
// eslint-disable-next-line
console.error(message);
}
});
async function openIfClosedAndGetContentId(trigger) {
let contentId = trigger.attributes['aria-owns'] && `${trigger.attributes['aria-owns'].value}`;
let content = contentId ? document.querySelector(`#${contentId}`) : undefined;
// If the dropdown is closed, open it
if (!content || content.classList.contains('ember-basic-dropdown-content-placeholder')) {
await click(trigger);
await settled();
contentId = `${trigger.attributes['aria-owns'].value}`;
}
return contentId;
}
trigger.scrollIntoView();
}
let isMultipleSelect = !!trigger.querySelector('.ember-power-select-trigger-multiple-input');
let contentId = await openIfClosedAndGetContentId(trigger);
let isDefaultSingleSelect = !!document.querySelector('.ember-power-select-search-input');
if (isMultipleSelect) {
await fillIn(trigger.querySelector('.ember-power-select-trigger-multiple-input'), value);
} else if (isDefaultSingleSelect) {
await fillIn('.ember-power-select-search-input', value);
} else { // It's probably a customized version
let inputIsInTrigger = !!trigger.querySelector('.ember-power-select-trigger input[type=search]');
if (inputIsInTrigger) {
await fillIn(trigger.querySelector('input[type=search]'), value);
} else {
await fillIn(`#${contentId} .ember-power-select-search-input[type=search]`, 'input');
}
}
return settled();
}
export default function getRfc232TestContext() {
// Support older versions of `ember-qunit` that don't have
// `@ember/test-helpers` (and therefore cannot possibly be running an
// rfc232/rfc268 test).
if (require.has('@ember/test-helpers')) {
let { getContext } = require('@ember/test-helpers');
return getContext();
}
}
async function openIfClosedAndGetContentId(trigger) {
let contentId = trigger.attributes['aria-owns'] && `${trigger.attributes['aria-owns'].value}`;
let content = contentId ? document.querySelector(`#${contentId}`) : undefined;
// If the dropdown is closed, open it
if (!content || content.classList.contains('ember-basic-dropdown-content-placeholder')) {
await click(trigger);
await settled();
contentId = `${trigger.attributes['aria-owns'].value}`;
}
return contentId;
}
import { dasherize } from '@ember/string';
import { assign } from '@ember/polyfills';
import { setRegistry } from '../../resolver';
import { setResolver, setApplication } from '@ember/test-helpers';
import require from 'require';
import App from '../../app';
import config from '../../config/environment';
const AppConfig = assign({ autoboot: false }, config.APP);
export const application = App.create(AppConfig);
export const resolver = application.Resolver.create({
namespace: application,
isResolverFromTestHelpers: true,
});
setResolver(resolver);
setApplication(application);
export function setResolverRegistry(registry) {
setRegistry(registry);
}
export default {
create() {
return resolver;
},
};
export function createCustomResolver(registry) {
if (require.has('ember-native-dom-event-dispatcher')) {
// the raw value looked up by ember and these test helpers
registry['event_dispatcher:main'] = require('ember-native-dom-event-dispatcher').default;