Skip to content

Commit

Permalink
Simplified tests and DOM structure
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiocruz committed Aug 22, 2016
1 parent 903e943 commit aa690e6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
13 changes: 11 additions & 2 deletions src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@ body {
font-size: 18px;
}

#badges {
text-align: center;
}

.course {
background: #F5F5F5;
border: 1px solid #ccc;
border-radius: 5px;
border: 1px solid #ccc;
box-shadow: 1px 1px 5px #EAEAEA;
display: inline-block;
height: 350px;
margin: 20px 10px;
padding: 15px 10px;
text-align: center;
width: 200px;
}

.course h3 {
Expand All @@ -28,3 +33,7 @@ body {
width: 150px;
margin-bottom: 20px;
}

.course a {
display: block;
}
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<div class="container">
<h1>jQuery Badges</h1>
<div id="badges" class="row"></div>
<div id="badges"></div>
</div>


Expand Down
20 changes: 4 additions & 16 deletions test/portfolio.spec.js → test/badges.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,29 +107,17 @@ describe('The webpage', () => {
assert(!!firstCourse);
});

it('should have elements with the correct class name', () => {
let firstCourse = badges.firstChild;
let classes = Array.from(firstCourse.classList);
assert(!!classes.find((className) => className === 'col-md-3'));
it('should have child with the course class name', () => {
const firstCourse = badges.firstChild;
const classes = Array.from(firstCourse.classList);
assert(!!classes.find((className) => className === 'course'));
});

it('should have x elements within the #badges', () => {
const courses = badges.childNodes;
assert(courses.length === mockData.courses.completed.length)
});

it('should have a div as a child', () => {
const firstCourseDiv = badges.firstChild.firstChild;
assert(!!firstCourseDiv);
assert(firstCourseDiv.nodeName.toLowerCase() === 'div')
});

it('should have child with the course class name', () => {
const firstCourseDiv = badges.firstChild.firstChild;
const classes = Array.from(firstCourseDiv.classList);
assert(!!classes.find((className) => className === 'course'));
});

it('should have h3 tags with the course titles', () => {
const courses = Array.from(badges.querySelectorAll('.course'));
courses.forEach((course, i) => {
Expand Down

0 comments on commit aa690e6

Please sign in to comment.