-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c869261
commit 78a2e89
Showing
5 changed files
with
77 additions
and
13 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const assert = require("chai").assert; | ||
const parse5 = require("parse5"); | ||
const cheerio = require("cheerio"); | ||
const helpers = require("../helpers"); | ||
|
||
describe("BookForm.vue", () => { | ||
it("should contain three labels with a `for` attribute @book-form-will-contain-labels", () => { | ||
const file = helpers.readFile("src/components/BookForm.vue"); | ||
const nodes = helpers.parseFile(file); | ||
const tagName = helpers.getHtmlTag("template", nodes); | ||
const content = parse5.serialize(tagName[0].content); | ||
const $ = cheerio.load(content); | ||
const label = $("form").find("label"); | ||
|
||
assert( | ||
label.length === 3, | ||
"The form doesn't have three `<label>` elements with a `for` attribute." | ||
); | ||
|
||
assert.hasAnyKeys( | ||
label.attr(), | ||
["for"], | ||
"The BookForm label does not have a `for` attribute containing `finishedReading` as its value." | ||
); | ||
|
||
assert.propertyVal( | ||
label.attr(), | ||
"for", | ||
"finishedReading", | ||
"The BookForm label does not have a `for` attribute containing `finishedReading` as its value." | ||
); | ||
|
||
assert( | ||
$('label[for="borrowed"]').length > 0, | ||
"The BookForm label does not have a `for` attribute containing `borrowed` as its value." | ||
); | ||
|
||
assert( | ||
$('label[for="bought"]').length > 0, | ||
"The BookForm label does not have a `for` attribute containing `bought` as its value." | ||
); | ||
|
||
assert( | ||
$('label[for="finishedReading"]') | ||
.text() | ||
.match(/\s*Finished\s*Reading/), | ||
"The BookForm does not have a label with a text of `Finished Reading`." | ||
); | ||
|
||
assert( | ||
$('label[for="borrowed"]') | ||
.text() | ||
.match(/\s*borrowed/), | ||
"The BookForm does not have a label with a text of `borrowed`." | ||
); | ||
|
||
assert( | ||
$('label[for="bought"]') | ||
.text() | ||
.match(/\s*bought/), | ||
"The BookForm does not have a label with a text of `bought`." | ||
); | ||
}); | ||
}); |
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
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
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