Skip to content

Commit

Permalink
Add E2E tests for home page
Browse files Browse the repository at this point in the history
  • Loading branch information
phildarnowsky committed Dec 19, 2019
1 parent 4c0616e commit a6a13d2
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 8 deletions.
97 changes: 97 additions & 0 deletions p4/tests/e2e/specs/pages/HomePageSpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
const deckData =
[
{
"id": 1,
"name": "German vocabulary",
"cards": [
{
"question": "die Bestätigung",
"canonical_answer": "confirmation",
"alternate_answers": [ "verification", "certificate", "endorsement" ]
},
{
"question": "die Geige",
"canonical_answer": "violin",
"alternate_answers": [ "fiddle" ]
},
{
"question": "reden",
"canonical_answer": "to converse",
"alternate_answers": [ "to talk", "converse", "talk" ]
}
]
},
{
"id": 2,
"name": "Chemical symbols",
"cards": [
{
"question": "C",
"canonical_answer": "carbon",
"alternate_answers": []
},
{
"question": "Fe",
"canonical_answer": "iron",
"alternate_answers": [ ]
}
]
},
{
"id": 3,
"name": "State capitals",
"cards": [
{
"question": "Montpelier",
"canonical_answer": "Vermont",
"alternate_answers": [ "VT" ]
},
{
"question": "Annapolis",
"canonical_answer": "Maryland",
"alternate_answers": [ "MD" ]
},
{
"question": "Albany",
"canonical_answer": "New York",
"alternate_answers": [ "NY" ]
},
{
"question": "Sacramento",
"canonical_answer": "California",
"alternate_answers": [ "CA" ]
}
]
}
]

describe('My First Test', () => {
beforeEach(function () {
cy.server()
cy.route({
method: 'GET',
url: '/phildarnowsky/e28_p3_api/decks',
response: JSON.stringify(deckData)
})
})

it('Visits the app root url', () => {
cy.visit('/')
cy.contains('h1', 'Available Decks')
})

it('Has a link to each available deck', () => {
cy.visit('/')
cy.contains('a', 'German vocabulary')
cy.contains('a', 'Chemical symbols')
cy.contains('a', 'State capitals')
cy.contains('a', 'Chemical symbols').click()
cy.contains('h1', 'Chemical symbols')
})

it('Has a link to the stats page', () => {
cy.visit('/')
cy.contains('a', 'View stats').click()
cy.contains('h1', 'Stats')
})
})
8 changes: 0 additions & 8 deletions p4/tests/e2e/specs/root.js

This file was deleted.

0 comments on commit a6a13d2

Please sign in to comment.