Skip to content

Instantly share code, notes, and snippets.

@mmun
Created December 9, 2015 15:45
Show Gist options
  • Save mmun/bf127ff453823140a5b4 to your computer and use it in GitHub Desktop.
Save mmun/bf127ff453823140a5b4 to your computer and use it in GitHub Desktop.
import { test } from 'qunit';
import Pretender from 'pretender';
import moduleForAcceptance from 'my-app/tests/helpers/module-for-acceptance';
export function json(status, payload) {
return [
status,
{ 'Content-Type': 'application/json; charset=utf-8' },
JSON.stringify(payload)
];
}
moduleForAcceptance('Acceptance | post-viewer', {
beforeEach() {
this.server = new Pretender();
},
afterEach() {
this.server.shutdown();
}
});
test('visiting /post-viewer/:post_id', function(assert) {
this.server.get('my_api/posts/123', function() {
return json(200, {
id: '123',
title: 'Rails is Omakase',
body: '...'
});
});
visit('/post-viewer/123');
andThen(function() {
assert.equal(currentURL(), '/post-viewer/123');
findWithAssert(`.post-title:contains('Rails is Omakase'`);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment