Skip to content

Instantly share code, notes, and snippets.

@derrickshowers
Created April 18, 2017 02:21
Show Gist options
  • Save derrickshowers/2951225af93306d71e92fe18ba98d957 to your computer and use it in GitHub Desktop.
Save derrickshowers/2951225af93306d71e92fe18ba98d957 to your computer and use it in GitHub Desktop.
Test Redirect
import Ember from 'ember';
export default Ember.Component.extend({
init() {
this._super();
this.foo()
},
redirectToSomewhere() {
// window.location = "blah.com";
console.log("here weeee go!")
},
foo() {
if (true) {
this.redirectToSomewhere();
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
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 { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('my-component', 'TODO: put something here', {
integration: true
});
test('Test Redirect', function(assert) {
let stubbedRedirectFunction = function() {
assert.ok(true, 'Redirect was successful');
}
this.set('stubbedRedirectFunction', stubbedRedirectFunction);
this.render(hbs`{{my-component redirectToSomewhere=stubbedRedirectFunction}}`);
expect(1);
});
import resolver from './helpers/resolver';
import {
setResolver
} from 'ember-qunit';
setResolver(resolver);
{
"version": "0.12.1",
"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.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment