Created
December 9, 2015 15:45
-
-
Save mmun/bf127ff453823140a5b4 to your computer and use it in GitHub Desktop.
This file contains 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 { 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