Skip to content

Instantly share code, notes, and snippets.

@samselikoff
Last active December 20, 2018 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save samselikoff/3fd2fee5400a95541905c54f525e243e to your computer and use it in GitHub Desktop.
Save samselikoff/3fd2fee5400a95541905c54f525e243e to your computer and use it in GitHub Desktop.
diff --git a/tests/acceptance/podcast-episode-test.js b/tests/acceptance/podcast-episode-test.js
new file mode 100644
index 0000000..cf3363e
--- /dev/null
+++ b/tests/acceptance/podcast-episode-test.js
@@ -0,0 +1,41 @@
+import { test } from 'qunit';
+import moduleForAcceptance from 'ember-map/tests/helpers/module-for-acceptance';
+
+moduleForAcceptance('Acceptance | Podcast episode page', {
+ beforeEach() {
+ this.episode = server.create('podcast-episode', { title: 'Podcast 1', slug: 'podcast-1', position: 1 });
+ server.create('podcast-episode', { title: 'Podcast 3', position: 3 });
+ server.create('podcast-episode', { title: 'Podcast 2', position: 2 });
+ server.create('podcast-episode', { title: 'Podcast 4', position: 4 });
+ server.create('podcast-episode', { title: 'Podcast 5', position: 5 });
+ }
+});
+
+test("it shows the episode's details", async function(assert) {
+ await visit(`/podcast/podcast-1`);
+
+ assert.dom('h1').includesText('Podcast 1');
+ assert.dom().includesText(this.episode.description);
+});
+
+test("the recent episodes section shows the 3 most recent episodes", async function(assert) {
+ await visit(`/podcast/podcast-1`);
+
+ let cards = document.querySelectorAll('[data-test-id="podcast-card"]');
+
+ assert.equal(cards.length, 3);
+ assert.dom(cards[0]).includesText('Podcast 5');
+ assert.dom(cards[1]).includesText('Podcast 4');
+ assert.dom(cards[2]).includesText('Podcast 3');
+});
+
+test("if the current episode is one of the 3 most recent, the recent episodes section shows the next most-recent episode", async function(assert) {
+ await visit(`/podcast/podcast-4`);
+
+ let cards = document.querySelectorAll('[data-test-id="podcast-card"]');
+
+ assert.equal(cards.length, 3);
+ assert.dom(cards[0]).includesText('Podcast 5');
+ assert.dom(cards[1]).includesText('Podcast 3');
+ assert.dom(cards[2]).includesText('Podcast 2');
+});
diff --git a/tests/acceptance/podcast-index-test.js b/tests/acceptance/podcast-index-test.js
new file mode 100644
index 0000000..263b3f4
--- /dev/null
+++ b/tests/acceptance/podcast-index-test.js
@@ -0,0 +1,32 @@
+import { test } from 'qunit';
+import moduleForAcceptance from 'ember-map/tests/helpers/module-for-acceptance';
+
+moduleForAcceptance('Acceptance | Podcast index page', {
+ beforeEach() {
+ server.create('podcast-episode', { title: 'Podcast 1', position: 1 });
+ server.create('podcast-episode', { title: 'Podcast 3', position: 3 });
+ server.create('podcast-episode', { title: 'Podcast 2', position: 2 });
+ server.create('podcast-episode', { title: 'Podcast 4', position: 4 });
+ }
+});
+
+test('it shows all podcast episodes ordered by descending position', async function(assert) {
+ await visit(`/podcast`);
+
+ let cards = document.querySelectorAll('[data-test-id="podcast-card"]');
+
+ assert.equal(cards.length, 4);
+
+ assert.dom(cards[0]).includesText('Podcast 4');
+ assert.dom(cards[1]).includesText('Podcast 3');
+ assert.dom(cards[2]).includesText('Podcast 2');
+ assert.dom(cards[3]).includesText('Podcast 1');
+});
+
+test('I can view a specific podcast episode', async function(assert) {
+ await visit(`/podcast`);
+ await click(`a:contains(Podcast 2)`)
+
+ assert.equal(currentRouteName(), "podcast.episode");
+ assert.dom('h1').includesText('Podcast 2');
+});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment