Skip to content

Commit

Permalink
failure message content tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jonfriskics committed Mar 22, 2018
1 parent 76f19f8 commit 435ff7a
Show file tree
Hide file tree
Showing 32 changed files with 72 additions and 72 deletions.
4 changes: 2 additions & 2 deletions test/unit/mocha/part1/app-should-use-book-list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ describe('App.vue', () => {

const ast = esprima.parse(script[0].childNodes[0].value, { sourceType: 'module' });
const data = esquery(ast, 'Property[key.name=data]');
assert(data.length > 0, 'data function return is not present');
assert(data.length > 0, 'The BookList\'s `data()` method\'s return is not present');

const results = esquery(data[0], 'Property[key.name=title] > .value[value="All Books"]');
assert(results.length > 0, 'title property is not defined with value of All Books');
assert(results.length > 0, 'The BookList\'s `title` property is not defined with value of `All Books`');
});
});
6 changes: 3 additions & 3 deletions test/unit/mocha/part1/app-vue-will-contain-book-list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ describe('App.vue', () => {
// Test for correct import statement
const ast = esprima.parse(script[0].childNodes[0].value, { sourceType: 'module' });
let results = esquery(ast, 'ImportDeclaration[source.value="./components/BookList"]');
assert(results.length > 0, './components/BookList was not imported');
assert(results.length > 0, '`./components/BookList` was not imported');

// Test for bookList definition in the component key
results = esquery(ast, 'Property[key.name=components] > ObjectExpression > Property[key.name=BookList]');
assert(results.length > 0, 'BookList is not defined under components property in object');
assert(results.length > 0, '`BookList` is not defined as a value in an object in the `components` property');

// Parse for HTML in template
const template = nodes.filter(node => node.nodeName === 'template');
Expand All @@ -40,6 +40,6 @@ describe('App.vue', () => {

// Test for booklist in the app div
results = document.querySelector('div#app book-list');
assert(results, 'BookList is not defined inside of a div with the id of app');
assert(results, 'The `<book-list>` element does not exist inside of a div with the id of app');
});
});
6 changes: 3 additions & 3 deletions test/unit/mocha/part1/book-list-has-all-elements.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ describe('BookList.vue', () => {

// Parse for template
const template = nodes.filter(node => node.nodeName === 'template');
assert(template.length > 0, 'BookList does not contain a template element');
assert(template.length > 0, 'The BookList.vue file does not contain a template element');

// Parse for script
const script = nodes.filter(node => node.nodeName === 'script');
assert(script.length > 0, 'BookList does not contain a script element');
assert(script.length > 0, 'The BookList.vue file does not contain a script element');

// Parse for style
const style = nodes.filter(node => node.nodeName === 'style');
assert(style.length > 0, 'BookList does not contain a style element');
assert(style.length > 0, 'The BookList.vue file does not contain a style element');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ describe('BookList.vue', () => {

// Test for booklist in the app div
const results = document.querySelector('h1');
assert(results.innerHTML === '{{title}}', 'BookList does not contain the {{title}} in an h1');
assert(results.innerHTML === '{{title}}', 'The BookList template does not contain the `{{title}}` in an `h1`');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ describe('BookList.vue', () => {

// Test for #app present in the styles
const results = parsed.cssRules.find(node => node.selectorText === 'h1, h2');
assert(results, 'The "h1, h2" selector is not present in your styles');
assert(results, 'The `"h1, h2"` selector is not present in BookList\'s styles');

// Test for one of the fonts present in font-family
assert(results.style['font-weight'].includes('normal'), 'Your font-weight is not set to normal');
assert(results.style['font-weight'].includes('normal'), 'The `font-weight` is not set to `normal` in BookList\'s styles');
});
});
4 changes: 2 additions & 2 deletions test/unit/mocha/part2/book-list-contains-list-styles.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ describe('BookList.vue', () => {

// Test for #app present in the styles
const results = parsed.cssRules.find(node => node.selectorText === 'ul');
assert(results, 'There is no ul present in your style section');
assert(results, 'There is no `ul` present in in BookList\'s styles');

// Test for one of the fonts present in font-family
assert(results.style['list-style-type'] === 'none', 'Your list-style-type is not set to none');
assert(results.style['list-style-type'] === 'none', 'The `ul` elements `list-style-type` is not set to `none` in BookList\'s styles');
});
});
2 changes: 1 addition & 1 deletion test/unit/mocha/part2/book-list-contains-static-li.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('BookList.vue', () => {
if (results.innerHTML.includes('book-item')) {
assert(true);
} else {
assert(results.innerHTML.includes('li'), 'BookList does not contain any li tags');
assert(results.innerHTML.includes('li'), 'The BookList template does not contain any `li` tags');
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ describe('BookList.vue', () => {
// TODO: add extra assert to check if the array is in data() first,
// then after that assert passes let these tests run to check the properties.
const results = esquery(ast, 'ExportDefaultDeclaration Property[key.name=data] Property[key.name="books"] Property[value.value="American Gods"]')
assert(results.length > 0, 'The book with a title of American Gods is not in your books array');
assert(results.length > 0, 'A book with a title of American Gods is not in your books array');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ describe('BookList.vue', () => {
if (results.innerHTML.includes('book-item')) {
assert(true);
} else {
assert(results.innerHTML.includes('li'), 'BookList does not contain any li tags');
assert(results.innerHTML.includes('{{book.title}}:{{book.author}}'), 'The li should have a interpolate "{{book.title}}:{{book.author}}"');
assert(results.innerHTML.includes('li'), 'The BookList template does not contain any `li` tags');
assert(results.innerHTML.includes('{{book.title}}:{{book.author}}'), 'The BookList template\'s `li` element does not contain these interpolated values `{{book.title}}:{{book.author}}`');
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ describe('BookList.vue', () => {
if (results.innerHTML.includes('book-item')) {
assert(true);
} else {
assert(results.innerHTML.includes('li'), 'BookList does not contain any li tags');
assert(results.innerHTML.includes('v-for="book in books"'), 'The li should have a v-for statement containing book in books');
assert(results.innerHTML.includes('li'), 'The BookList template does not contain any `li` tags');
assert(results.innerHTML.includes('v-for="book in books"'), 'The BookList template\'s `li` tag does not have a `v-for` statement containing `book in books`');
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ describe('BookItem.vue', () => {

// Test for #app present in the styles
const results = parsed.cssRules.find(node => node.selectorText === 'li');
assert(results, 'There is no li present in your style section');
assert(results, 'There is no `li` selector in BookItem\'s styles');

// Test for one of the fonts present in font-family
assert(results.style.display === 'block', 'Your li display is not set to block');
assert(results.style.display === 'block', 'The li `display` property is not set to `block` in BookItem\'s styles');
});
});

Expand All @@ -49,6 +49,6 @@ describe('BookList.vue', () => {

// Test for #app present in the styles
const results = parsed.cssRules.find(node => node.selectorText === 'li');
assert(results === undefined, 'There should not be a li present in your style section');
assert(results === undefined, 'There should not be any `li` rules present in BookList\'s styles');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ describe('BookItem.vue', () => {

// Test for booklist in the app div
const results = document.querySelector('li');
assert(results.innerHTML.includes('book.title'), 'BookItem does not contain an li with book data');
assert(results.innerHTML.includes('book.title'), 'The BookItem template does not contain an `li` tag');
});
});
4 changes: 2 additions & 2 deletions test/unit/mocha/part3/book-item-contains-props.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ describe('BookItem.vue', () => {
const ast = esprima.parse(script[0].childNodes[0].value, { sourceType: 'module' });

let results = esquery(ast, 'ExportDefaultDeclaration Property[key.name="name"] Literal[value="BookItem"]');
assert(results.length > 0, 'The `BookItem` name was not defined under export default');
assert(results.length > 0, 'The BookItem component does not have a `name` property with the value of `BookItem` defined in the `export default` section');

results = esquery(ast, 'ExportDefaultDeclaration Property[key.name="props"] Literal[value="book"]');
assert(results.length > 0, 'Props was not defined with an array value of book');
assert(results.length > 0, 'The BookItem component does not have a `props` property with an array value containing the string `book` defined in the `export default` section');
});
});
6 changes: 3 additions & 3 deletions test/unit/mocha/part3/book-item-exists.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ describe('BookItem.vue', () => {
const doc = parse5.parseFragment(file.replace(/\n/g, ''), { locationInfo: true });
const nodes = doc.childNodes;
const script = nodes.filter(node => node.nodeName === 'script');
assert(script.length > 0, 'No script tag exists in BookItem.vue');
assert(script.length > 0, 'No `script` tag exists in BookItem.vue');

const template = nodes.filter(node => node.nodeName === 'template');
assert(template.length > 0, 'No template tag exists in BookItem.vue');
assert(template.length > 0, 'No `template` tag exists in BookItem.vue');

const style = nodes.filter(node => node.nodeName === 'style');
assert(style.length > 0, 'No style tag exists in BookItem.vue');
assert(style.length > 0, 'No `style` tag exists in BookItem.vue');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ describe('BookList.vue', () => {
// Test for correct import statement
const ast = esprima.parse(script[0].childNodes[0].value, { sourceType: 'module' });
let results = esquery(ast, 'ImportDeclaration[source.value="./BookItem"]');
assert(results.length > 0, './BookItem was not imported');
assert(results.length > 0, 'The `BookItem` class was not imported from `./BookItem` In BookList.vue');

results = esquery(ast, 'ImportSpecifier');
assert(results.length == 0, 'do not use curly brace style importing for vue component imports');
assert(results.length == 0, 'Your import statement currently uses curly braces `{ }` to import the `BookItem` component - please replace that with just the name `BookItem`');
});
});
2 changes: 1 addition & 1 deletion test/unit/mocha/part4/book-list-contains-book-item.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ describe('BookList.vue', () => {
// Test for bookList definition in the component key
const ast = esprima.parse(script[0].childNodes[0].value, { sourceType: 'module' });
const results = esquery(ast, 'Property[key.name=components] > ObjectExpression > Property[key.name=BookItem]');
assert(results.length > 0, 'BookItem is not defined under components property in object');
assert(results.length > 0, 'The value of the `components` property is not an object containing `BookItem` in BookList.vue');
});
});
6 changes: 3 additions & 3 deletions test/unit/mocha/part4/book-list-now-loops-book-item.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ describe('BookList.vue', () => {

// Test for booklist in the app div
const results = document.querySelector('ul');
assert(results.innerHTML.includes('book-item'), 'BookList does not contain any book-item tags');
assert(results.innerHTML.includes('v-for="book in books"'), 'The book-item should have a v-for statement containing book in books');
assert(results.innerHTML.includes(':book="book"'), 'you need to define the book prop in the book-item tag');
assert(results.innerHTML.includes('book-item'), 'The BookList template does not contain any `book-item` tags');
assert(results.innerHTML.includes('v-for="book in books"'), 'The `book-item` tag does not have a `v-for` statement containing `book in books`');
assert(results.innerHTML.includes(':book="book"'), 'The `book-item` tag does not have a `book` prop with the value of `book`');
});
});
6 changes: 3 additions & 3 deletions test/unit/mocha/part5/book-form-contains-data.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ describe('BookForm.vue', () => {

const ast = esprima.parse(script[0].childNodes[0].value, { sourceType: 'module' });
const data = esquery(ast, 'Property[key.name=data]');
assert(data.length > 0, 'data function return is not present');
assert(data.length > 0, 'The BookList\'s `data()` method\'s return is not present');

let results = esquery(data[0], 'Property[key.name=bookTitle] > .value[value=""]');
assert(results.length > 0, 'bookTitle property is not defined with a blank string value');
assert(results.length > 0, 'The BookList\'s `bookTitle` property is not defined with value of `\'\'`');

results = esquery(data[0], 'Property[key.name=bookAuthor] > .value[value=""]');
assert(results.length > 0, 'bookAuthor property is not defined with a blank string value');
assert(results.length > 0, 'The BookList\'s `bookAuthor` property is not defined with value of `\'\'`');
});
});
2 changes: 1 addition & 1 deletion test/unit/mocha/part5/book-form-contains-form-data.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ describe('BookForm.vue', () => {

// Test for for form existance
const results = document.querySelector('form');
assert(results.length > 0, 'BookForm does not contain a form');
assert(results.length > 0, 'The BookForm template does not contain a `form` tag');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ describe('BookForm.vue', () => {

const ast = esprima.parse(script[0].childNodes[0].value, { sourceType: 'module' });
const methods = esquery(ast, 'Property[key.name=methods]');
assert(methods.length > 0, 'the methods declaration is not present');
assert(methods.length > 0, 'The BookForm\'s `methods` declaration is not present');
});
});
4 changes: 2 additions & 2 deletions test/unit/mocha/part5/book-form-contains-props.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ describe('BookForm.vue', () => {
const ast = esprima.parse(script[0].childNodes[0].value, { sourceType: 'module' });

let results = esquery(ast, 'ExportDefaultDeclaration Property[key.name="name"] Literal[value="BookForm"]');
assert(results.length > 0, './BookForm does not have a name property with the value of BookForm');
assert(results.length > 0, 'The BookForm does not have a `name` property with the value of `BookForm`');

results = esquery(ast, 'ExportDefaultDeclaration Property[key.name="props"] Literal[value="books"]');
assert(results.length > 0, './BookForm does not have a props property with the value of books');
assert(results.length > 0, 'The BookForm does not have a `props` property with the value of `[\'books\']`');
});
});
6 changes: 3 additions & 3 deletions test/unit/mocha/part5/book-form-emits-add-book.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ describe('BookForm.vue', () => {

const ast = esprima.parse(script[0].childNodes[0].value, { sourceType: 'module' });
const methods = esquery(ast, 'Property[key.name=methods]');
assert(methods.length > 0, 'the methods declaration is not present');
assert(methods.length > 0, 'The BookForm\'s `methods` declaration is not present');

let results = esquery(methods[0], 'Identifier[name="bookSubmit"]');
assert(results.length > 0, 'bookSubmit method is not defined');
assert(results.length > 0, 'The BookForm\'s `methods` object is not defining a `bookSubmit()` method');

results = esquery(methods[0], 'CallExpression[arguments] > Literal[value="addBook"]');
assert(results.length > 0, 'addBook is not present in your this call expression');
assert(results.length > 0, 'The `bookSubmit()` method is emitting a call to `addBook`');
});
});
6 changes: 3 additions & 3 deletions test/unit/mocha/part5/book-form-exists.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ describe('BookForm.vue', () => {
const doc = parse5.parseFragment(file.replace(/\n/g, ''), { locationInfo: true });
const nodes = doc.childNodes;
const script = nodes.filter(node => node.nodeName === 'script');
assert(script, 'No script tag exists in BookForm.vue');
assert(script, 'No `script` tag exists in BookForm.vue');

const template = nodes.filter(node => node.nodeName === 'template');
assert(template, 'No template tag exists in BookForm.vue');
assert(template, 'No `template` tag exists in BookForm.vue');

const style = nodes.filter(node => node.nodeName === 'style');
assert(style, 'No style tag exists in BookForm.vue');
assert(style, 'No `style` tag exists in BookForm.vue');
});
});
6 changes: 3 additions & 3 deletions test/unit/mocha/part5/book-form-form-has-on-submit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ describe('BookForm.vue', () => {

// Test for for form existance
const results = document.querySelector('form');
assert(results.length > 0, 'BookForm does not contain a form');
assert(results.length > 0, 'The BookForm template does not contain a `form` tag');

assert(results.outerHTML.includes('submit.prevent'), 'BookForm does not have an v-on:submit.prevent');
assert(results.outerHTML.includes('submit.prevent'), 'The `form` tag in the BookForm template does not include `v-on:submit.prevent`');

assert(results.outerHTML.includes('bookSubmit(bookTitle, bookAuthor)'), 'BookForm does not call bookSubmit');
assert(results.outerHTML.includes('bookSubmit(bookTitle, bookAuthor)'), 'The `v-on:submit.prevent` called in BookForm\'s `form` tag does not call the `bookSubmit()` method');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ describe('BookForm.vue', () => {
const results = document.querySelector('form');
assert(results.length > 0, 'BookForm does not contain a form');

assert(results.innerHTML.includes('v-model="bookTitle"'), 'BookForm does not have an v-model for bookTitle');
assert(results.innerHTML.includes('v-model="bookTitle"'), 'The BookForm template does not have an input with a `v-model` attribute for `bookTitle`');

assert(results.innerHTML.includes('v-model="bookAuthor"'), 'BookForm does not have an v-model for bookAuthor');
assert(results.innerHTML.includes('v-model="bookAuthor"'), 'The BookForm template does not have an input with a `v-model` attribute for `bookAuthor`');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ describe('BookForm.vue', () => {

const ast = esprima.parse(script[0].childNodes[0].value, { sourceType: 'module' });
const methods = esquery(ast, 'Property[key.name=methods]');
assert(methods.length > 0, 'the methods declaration is not present');
assert(methods.length > 0, 'The BookForm\'s `methods` declaration is not present');

let results = esquery(methods[0], 'Identifier[name="bookSubmit"]');
assert(results.length > 0, 'bookSubmit method is not defined');
assert(results.length > 0, 'The BookForm\'s `methods` object is not defining a `bookSubmit()` method');

results = esquery(methods[0], 'Property[key.name="bookSubmit"] > FunctionExpression > Identifier[name="bookTitle"]');
assert(results.length > 0, 'bookTitle is not an argument inside the the bookSubmit Method');
assert(results.length > 0, '`bookTitle` is not an argument in the call to `bookSubmit()`');

results = esquery(methods[0], 'Property[key.name="bookSubmit"] > FunctionExpression > Identifier[name="bookAuthor"]');
assert(results.length > 0, 'bookAuthor is not an argument inside the the bookSubmit Method');
assert(results.length > 0, '`bookAuthor` is not an argument in the call to `bookSubmit()`');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ describe('BookList.vue', () => {

const ast = esprima.parse(script[0].childNodes[0].value, { sourceType: 'module' });
const methods = esquery(ast, 'Property[key.name=methods]');
assert(methods.length > 0, 'the methods declaration is not present');
assert(methods.length > 0, 'The BookForm\'s `methods` declaration is not present');

let results = esquery(methods[0], 'Identifier[name="appendBook"]');
assert(results.length > 0, 'appendBook method is not defined');
assert(results.length > 0, 'The BookForm\'s `methods` object is not defining an `appendBook()` method');

results = esquery(methods[0], 'Property[key.name="appendBook"] > FunctionExpression > Identifier[name="bookTitle"]');
assert(results.length > 0, 'bookTitle is not an argument inside the the appendBook Method');
assert(results.length > 0, 'The `appendBook()` method is not being called with `bookTitle` as the first argument');

results = esquery(methods[0], 'Property[key.name="appendBook"] > FunctionExpression > Identifier[name="bookAuthor"]');
assert(results.length > 0, 'bookAuthor is not an argument inside the the appendBook Method');
assert(results.length > 0, 'The `appendBook()` method is not being called with `bookAuthor` as the first argument');
});
});
Loading

0 comments on commit 435ff7a

Please sign in to comment.