Created
January 30, 2017 12:28
-
-
Save jelhan/068e0c0fd7240e54c98972002fc2e34f to your computer and use it in GitHub Desktop.
New Twiddle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Service.extend({ | |
array: [], | |
prop: 0 | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default function destroyApp(application) { | |
Ember.run(application, 'destroy'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Resolver from '../../resolver'; | |
import config from '../../config/environment'; | |
const resolver = Resolver.create(); | |
resolver.namespace = { | |
modulePrefix: config.modulePrefix, | |
podModulePrefix: config.podModulePrefix | |
}; | |
export default resolver; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import resolver from './helpers/resolver'; | |
import { | |
setResolver | |
} from 'ember-qunit'; | |
setResolver(resolver); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { moduleFor, test } from 'ember-qunit'; | |
import Ember from 'ember'; | |
const { run } = Ember; | |
moduleFor('service:my-service', 'TODO: put something here', { | |
}); | |
test('array: first test', function(assert) { | |
let service = this.subject(); | |
assert.equal(service.get('array.length'), 0, 'array is empty as default'); | |
run(() => { | |
service.get('array').pushObject('foo'); | |
}); | |
assert.equal(service.get('array.length'), 1, 'array contains one element after pushObject'); | |
assert.deepEqual(service.get('array'), ['foo'], 'array contains newly pushed element'); | |
}); | |
test('array: second test', function(assert) { | |
let service = this.subject(); | |
assert.equal(service.get('array.length'), 0, 'array is empty as default'); | |
run(() => { | |
service.get('array').pushObject('bar'); | |
}); | |
assert.equal(service.get('array.length'), 1, 'array contains one element after pushObject'); | |
assert.deepEqual(service.get('array'), ['bar'], 'array contains newly pushed element'); | |
}); | |
test('property: first test', function(assert) { | |
let service = this.subject(); | |
assert.equal(service.get('prop'), 0, 'defaults to zero'); | |
run(() => { | |
service.incrementProperty('prop'); | |
}); | |
assert.equal(service.get('prop'), 1, 'is one after incrementing'); | |
}); | |
test('property: second test', function(assert) { | |
let service = this.subject(); | |
assert.equal(service.get('prop'), 0, 'defaults to zero'); | |
run(() => { | |
service.incrementProperty('prop'); | |
}); | |
assert.equal(service.get('prop'), 1, 'is one after incrementing'); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.11.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.10.2", | |
"ember-data": "2.11.0", | |
"ember-template-compiler": "2.10.2", | |
"ember-testing": "2.10.2" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment