Skip to content

Instantly share code, notes, and snippets.

@MilkyWayJoe
Created March 3, 2016 22:07
Show Gist options
  • Save MilkyWayJoe/9552de0026ebd47633b4 to your computer and use it in GitHub Desktop.
Save MilkyWayJoe/9552de0026ebd47633b4 to your computer and use it in GitHub Desktop.
XYZ
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
{{link-to 'Home' 'index'}} |
{{link-to 'BLAH' 'blah'}}
<hr>
<br>
{{outlet}}
<br>
<br>
import Ember from 'ember';
export default Ember.Route.extend({
});
<div class="blah-blah">
<button type="button" id="blah_btn">BLAH</button>
</div>
<em>"Ain't nobody got time for that"</em>
<br />
- Sweet Brown
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none'
});
Router.map(function() {
this.route('blah');
});
export default Router;
import { test } from 'qunit';
import moduleForAcceptance from '../../tests/helpers/module-for-acceptance';
import ember from 'ember';
let $ = ember.$;
moduleForAcceptance('TODO: put something here');
test('visiting /blah', function(assert) {
expect(3);
visit('/blah');
andThen(function() {
assert.equal(currentURL(), '/blah');
assert.equal($('button#blah_btn').length, 1, "expects a button to exist");
assert.equal($('button#blah_btn').text(), "BLAH", "expects a button to exist");
});
});
import Ember from 'ember';
export default function destroyApp(application) {
Ember.run(application, 'destroy');
}
import { module } from 'qunit';
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';
export default function(name, options = {}) {
module(name, {
beforeEach() {
this.application = startApp();
if (options.beforeEach) {
options.beforeEach.apply(this, arguments);
}
},
afterEach() {
destroyApp(this.application);
if (options.afterEach) {
options.afterEach.apply(this, arguments);
}
}
});
}
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';
export default function startApp(attrs) {
let application;
let attributes = Ember.merge({rootElement: "#test-root"}, config.APP);
attributes = Ember.merge(attributes, attrs); // use defaults, but you can override;
Ember.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('route:blah', 'TODO: put something here', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});
test('it exists', function(assert) {
let route = this.subject();
assert.ok(route);
});
{
"version": "0.6.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": true
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.3.1/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.3.3/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment