-
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
4935a88
commit c869261
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
test/unit/mocha/part6/form-should-have-radio-button.spec.js
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,33 @@ | ||
const assert = require("chai").assert; | ||
const parse5 = require("parse5"); | ||
const cheerio = require("cheerio"); | ||
const helpers = require("../helpers"); | ||
|
||
describe("BookForm.vue", () => { | ||
it("should contain a radio with a `v-model` directive @book-form-will-contain-radio", () => { | ||
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 radio = $("form input[type=radio]"); | ||
|
||
assert( | ||
radio.length == 2, | ||
"The form doesn't have two `<input>` elements with a `type` of `radio`" | ||
); | ||
|
||
assert.hasAnyKeys( | ||
radio.attr(), | ||
["v-model"], | ||
"The BookForm radio does not have a `v-model` directive containing `bookData.ownership` as its value" | ||
); | ||
|
||
assert.propertyVal( | ||
radio.attr(), | ||
"v-model", | ||
"bookData.ownership", | ||
"The BookForm radio does not have a `v-model` directive containing `bookData.finishedReading` as its value" | ||
); | ||
}); | ||
}); |