diff --git a/test/unit/mocha/part6/form-should-have-checkbox.spec.js b/test/unit/mocha/part6/form-should-have-checkbox.spec.js index bb5f7d87..72fc5d7c 100644 --- a/test/unit/mocha/part6/form-should-have-checkbox.spec.js +++ b/test/unit/mocha/part6/form-should-have-checkbox.spec.js @@ -14,20 +14,20 @@ describe("BookForm.vue", () => { assert( checkbox.length > 0, - "The form doesn't have an `` element with a `type` of `checkbox`" + "The form doesn't have an `` element with a `type` of `checkbox`." ); assert.hasAnyKeys( checkbox.attr(), ["v-model"], - "The BookForm checkbox does not have a `v-model` directive containing `bookData.finishedReading` as its value" + "The BookForm checkbox does not have a `v-model` directive containing `bookData.finishedReading` as its value." ); assert.propertyVal( checkbox.attr(), "v-model", "bookData.finishedReading", - "The BookForm checkbox does not have a `v-model` directive containing `bookData.finishedReading` as its value" + "The BookForm checkbox does not have a `v-model` directive containing `bookData.finishedReading` as its value." ); }); }); diff --git a/test/unit/mocha/part6/form-should-have-labels.spec.js b/test/unit/mocha/part6/form-should-have-labels.spec.js new file mode 100644 index 00000000..0da715b4 --- /dev/null +++ b/test/unit/mocha/part6/form-should-have-labels.spec.js @@ -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 `