Last active
February 10, 2017 09:36
-
-
Save amk221/42f680ffe9f245a76c4e87564c36cdec to your computer and use it in GitHub Desktop.
Promise Proxy integration test
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 RSVP from 'rsvp'; | |
import computedPromise from "ember-cpm/macros/computed-promise"; | |
export default Ember.Component.extend({ | |
proxy: computedPromise(function() { | |
return this.getAttr('my-promise'); | |
}) | |
}); |
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 { moduleForComponent, test } from 'ember-qunit'; | |
import hbs from 'htmlbars-inline-precompile'; | |
import RSVP from 'rsvp'; | |
import wait from 'ember-test-helpers/wait'; | |
const { resolve, reject } = RSVP; | |
moduleForComponent('my-component', { | |
integration: true | |
}); | |
test('successful', function(assert) { | |
this.set('myPromise', resolve({ value: 'Yey!' })); | |
this.render(hbs`{{my-component my-promise=myPromise}}`); | |
return wait().then(() => { | |
assert.equal(this.$().text().trim(), 'Success: Yey!', | |
'displays success if promise resolves'); | |
}); | |
}); | |
test('unsuccessful (with reason)', function(assert) { | |
this.set('myPromise', reject({ message: 'Soz :(' })); | |
this.render(hbs`{{my-component my-promise=myPromise}}`); | |
return wait().catch(() => { | |
assert.equal(this.$().text().trim(), 'Failed: Soz :(', | |
'displays error if promise rejects'); | |
}); | |
}); | |
test('unsuccessful (without reason)', function(assert) { | |
this.set('myPromise', reject()); | |
this.render(hbs`{{my-component my-promise=myPromise}}`); | |
return wait().then(() => { | |
assert.equal(this.$().text().trim(), 'Failed:', | |
'displays error if promise rejects'); | |
}); | |
}); |
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
{ | |
"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": { | |
"ember-cpm": "3.0.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment