-
-
Save Turbo87/68f4707c190b8e5b8bc9d3f22822d61c to your computer and use it in GitHub Desktop.
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
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 { module, test } from 'qunit'; | |
+import { setupApplicationTest } from 'ember-qunit'; | |
+ | |
+module('Acceptance | Podcast episode page', function(hooks) { | |
+ setupApplicationTest(hooks); | |
+ | |
+ hooks.beforeEach(function() { | |
+ 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 { module, test } from 'qunit'; | |
+import { setupApplicationTest } from 'ember-qunit'; | |
+ | |
+module('Acceptance | Podcast index page', function(hooks) { | |
+ setupApplicationTest(hooks); | |
+ | |
+ hooks.beforeEach(function() { | |
+ 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