Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function open (hook = 'select') {
// In a real browser when you click on the select with your mouse a
// focusin event is fired on the component. However when using jQuery's
// click() method the focusin is not fired so we are programitcally
// triggering that in this test.
$hook(hook).click().trigger('focusin')
return wait()
}
destItemIdx = items.indexOf(destItem) + 1;
items.insertAt(destItemIdx, sourceItem);
} else {
// native array
destItem = items[destItemIdx];
sourceItem = items[sourceItemIdx];
items.splice(sourceItemIdx, 1);
destItemIdx = items.indexOf(destItem) + 1;
items.splice(destItemIdx, 0, sourceItem);
// if we are not using Ember Arrays we need to set `items` to a new array
// instance to trigger a recompute on `virtualComponents`
context.set('items', [].concat(items));
}
});
return wait();
}
export default function() {
return wait().then(() => {
return new EmberPromise((resolve) => {
// Two RAFs needed since we take 3 frames to do the initial render
requestAnimationFrame(() => requestAnimationFrame((resolve)));
});
});
}
QUnit.module(module.name, {
beforeEach() {
module.setup();
},
afterEach() {
module.teardown();
}
});
}
async function testWait() {
await wait();
}
if (hasEmberVersion(2, 10)) {
// ...
}
// https://github.com/emberjs/ember-test-helpers/blob/f07e86914f2a3823c4cb6787307f9ba2bf447e68/tests/unit/setup-context-test.js
QUnit.test('it sets up this.owner', function(this: TestContext, assert: Assert) {
const { owner } = this;
assert.ok(owner, 'owner was setup');
assert.equal(typeof owner.lookup, 'function', 'has expected lookup interface');
if (hasEmberVersion(2, 12)) {
assert.equal(typeof owner.factoryFor, 'function', 'has expected factory interface');
}
});
QUnit.test('can pauseTest to be resumed "later"', async function(this: TestContext, assert: Assert) {
const promise = this.pauseTest();
function wrapper() {
var context = getContext();
var result = callback.apply(context, arguments);
function failTestOnPromiseRejection(reason) {
var message;
if (reason instanceof Error) {
message = reason.stack;
if (reason.message && message && message.indexOf(reason.message) < 0) {
// PhantomJS has a `stack` that does not contain the actual
// exception message.
message = Ember.inspect(reason) + "\n" + message;
}
} else {
message = Ember.inspect(reason);
}
ok(false, message);
import { deprecate } from '@ember/application/deprecations';
import { tryInvoke } from '@ember/utils';
import { run } from '@ember/runloop';
import { merge } from '@ember/polyfills';
import Ember from 'ember';
import TestModule from 'ember-test-helpers/test-module';
import { getResolver } from 'ember-test-helpers/test-resolver';
import { createModule } from 'ember-qunit/qunit-module';
var TestModuleForView = TestModule.extend({
init: function(viewName, description, callbacks) {
this.viewName = viewName;
this._super.call(this, 'component:' + viewName, description, callbacks);
this.setupSteps.push(this.setupView);
},
initNeeds: function() {
this.needs = [];
// toplevel refers to class extended from Ember.View
if (this.subjectName !== 'component:toplevel') {
this.needs.push(this.subjectName);
}
if (this.callbacks.needs) {
this.needs = this.needs.concat(this.callbacks.needs);
delete this.callbacks.needs;
}
},
export function flushScrollAndWait() {
return wait().then(() => {
return new Ember.RSVP.Promise((resolve) => {
window.requestAnimationFrame(resolve);
});
});
}
export default function(app) {
let ctx = { app };
Test.registerWaiter(ctx, hasNoIframe);
return wait().then(() => {
Test.unregisterWaiter(ctx, hasNoIframe);
return RSVP.resolve();
}).then(() => {
return new RSVP.Promise(function (resolve) {
run.later(resolve, 10);
});
});
}
async function testWait() {
await wait();
}
export function replaceArray(context, items) {
const oldItems = context.get('items');
run(() => {
if (EmberArray.detect(oldItems)) {
context.set('items', A(items));
} else {
context.set('items', items);
}
});
return wait();
}