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);
});
test('function callback with two args', function(assert) {
const elemIds = findAll('.button-class').forEach(function(elem, i) {
assert.equal(element.id, `button${index}`);
});
});
test('transforms get() correctly', function(assert) {
assert.ok(findAll('.foo bar')[3]);
const otherGet = someOtherObj.get(1);
});
test('anonymous function callback with two args', function(assert) {
this.render(hbs`{{foo-bar}}`);
const elemIds = findAll('.button-class').forEach((val, i) => {
assert.equal(element.id, `button${index}`);
});
});
test('transforms get() correctly', function(assert) {
assert.ok(findAll('.foo')[1]);
const otherGet = someOtherObj.get(1);
});
export default async function(name, selections) {
if (!isEmpty(name)) {
await fillIn('.participation .name input', name);
}
const isFreeText = findAll('.participation .selections .radio').length > 0 ? false : true;
for (let [index, selection] of selections.entries()) {
if (!isEmpty(selection)) {
if (isFreeText) {
await fillIn(`.participation .selections .form-group:nth-child(${index + 1}) input`, selection);
} else {
await click(`.participation .selections .form-group:nth-child(${index + 1}) .${selection}.radio input`);
}
}
}
await click('.participation button[type="submit"]');
await settled();
}
export default function findByText(selectorOrElements, text) {
let elements = selectorOrElements;
if (typeof selectorOrElements === 'string') {
elements = findAll(selectorOrElements);
}
return elements.find((el) => el.textContent.includes(text));
}
assert.ok(this.$('.foo:parent').length);
assert.ok(this.$('.foo:password').length);
assert.ok(this.$('.foo:radio').length);
assert.ok(this.$('.foo:reset').length);
assert.ok(findAll('.foo:checked').length);
assert.ok(this.$(':selected').length);
assert.ok(this.$('.foo:submit').length);
assert.ok(this.$('.foo:text').length);
assert.ok(this.$('.foo:visible').length);
assert.ok(this.$(JQEXTENSION_SELECTOR_AS_LOCAL_CONST).length);
assert.ok(this.$(ANY_SELECTOR_AS_IMPORTED_CONST).length);
assert.ok(this.$(':eq(0)').length);
assert.ok(findAll(find('.foo')).length);
assert.ok(findAll('.foo')[1].length);
assert.ok(findAll('.foo:first-child').length);
assert.ok(findAll('.foo:last-child').length);
assert.ok(findAll(NORMAL_SELECTOR).length);
assert.ok(this.$(NORMAL_PSEUDO_SELECTOR).length);
});
const find = wrap(function * (app, selector, options = {}) {
let startedAt = + new Date();
let timeoutMs = options.timeout;
let count = typeof options.count === 'undefined' ? 1 : options.count;
let isSettled = false;
settled().then(() => {
isSettled = true;
});
while(true) {
let els = findAll(selector);
if (els.length === count) {
return raw([...els]);
} else {
if (timeoutMs) {
let now = + new Date();
if (now - startedAt > timeoutMs) {
throw new Error(`Tried to find ${count} occurrence(s) of "${selector}" within ${timeoutMs}ms, instead found ${els.length}`);
}
} else {
if (isSettled) {
throw new Error(`Tried to find ${count} occurrence(s) of "${selector}" before test waiters settled, instead found ${els.length}`);
}
}
yield rawTimeout(15);
assert.ok(this.$('.foo:password').length);
assert.ok(this.$('.foo:radio').length);
assert.ok(this.$('.foo:reset').length);
assert.ok(findAll('.foo:checked').length);
assert.ok(this.$(':selected').length);
assert.ok(this.$('.foo:submit').length);
assert.ok(this.$('.foo:text').length);
assert.ok(this.$('.foo:visible').length);
assert.ok(this.$(JQEXTENSION_SELECTOR_AS_LOCAL_CONST).length);
assert.ok(this.$(ANY_SELECTOR_AS_IMPORTED_CONST).length);
assert.ok(this.$(':eq(0)').length);
assert.ok(findAll(find('.foo')).length);
assert.ok(findAll('.foo')[1].length);
assert.ok(findAll('.foo:first-child').length);
assert.ok(findAll('.foo:last-child').length);
assert.ok(findAll(NORMAL_SELECTOR).length);
assert.ok(this.$(NORMAL_PSEUDO_SELECTOR).length);
});