Skip to content

Instantly share code, notes, and snippets.

@danwenzel
Last active January 30, 2018 19:28
Show Gist options
  • Save danwenzel/5fdb6f48db88cb9a342f6c1683f7b9a3 to your computer and use it in GitHub Desktop.
Save danwenzel/5fdb6f48db88cb9a342f6c1683f7b9a3 to your computer and use it in GitHub Desktop.
ember-concurrency issue
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
import { task } from 'ember-concurrency';
export default Ember.Controller.extend({
init() {
this._super(...arguments);
this.get('myTask').perform();
},
myTask: task(function * () {
yield;
})
});
import Ember from 'ember';
import { task } from 'ember-concurrency';
export default Ember.Route.extend({
init() {
this._super(...arguments);
this.get('myTask').perform();
},
myTask: task(function * () {
yield;
})
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
import Ember from 'ember';
export default function destroyApp(application) {
Ember.run(application, 'destroy');
}
import Resolver from '../../resolver';
import config from '../../config/environment';
const resolver = Resolver.create();
resolver.namespace = {
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix
};
export default resolver;
import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';
const { run } = Ember;
const assign = Ember.assign || Ember.merge;
export default function startApp(attrs) {
let application;
let attributes = assign({rootElement: "#test-root"}, config.APP);
attributes = assign(attributes, attrs); // use defaults, but you can override;
run(() => {
application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
});
return application;
}
import resolver from './helpers/resolver';
import {
setResolver
} from 'ember-qunit';
setResolver(resolver);
import { moduleFor, test } from 'ember-qunit';
moduleFor('controller:my-controller', 'Unit | Controller | my-controller', {
});
test('it works without wrapping in a run', function(assert) {
assert.expect(1);
const controller = this.subject();
assert.ok(true);
});
test('it works wrapping in a run', function(assert) {
assert.expect(1);
Ember.run(() => {
const controller = this.subject();
assert.ok(true);
});
});
import { moduleFor, test } from 'ember-qunit';
moduleFor('route:my-route', 'Unit | Route | my-route', {
});
test('it works without wrapping in a run', function(assert) {
assert.expect(1);
const controller = this.subject();
assert.ok(true);
});
test('it works wrapping in a run', function(assert) {
assert.expect(1);
Ember.run(() => {
const controller = this.subject();
assert.ok(true);
});
});
{
"version": "0.13.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": true
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.13.0",
"ember-template-compiler": "2.13.0",
"ember-testing": "2.13.0"
},
"addons": {
"ember-data": "2.13.2",
"ember-concurrency": "0.8.6"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment