Skip to content

Commit 1608c00

Browse files
committed
Added specs for the portfolio
1 parent b26894b commit 1608c00

4 files changed

Lines changed: 84 additions & 81 deletions

File tree

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@ npm start
1919

2020
Complete the following tasks to complete this project.
2121

22-
### Convert the Header to semantic HTML.
22+
### Convert the Header
2323

2424
The element with a class of "header" isn't using the most semantic HTML tag it could be using. Switch it to use an element that most accurately wraps the header content for a page.
25+
26+
### Semantic Navigation
27+
28+
Our `.nav` element in the header of the page isn't using the most semantic HTML tags it could be using. `ul` is the correct one for this list of navigation items, but we should wrap this element with a more semantic element to indicate it is a navigation. Go ahead and add this.
29+
30+
### Create Sections
31+
32+
Each of the main content areas of our portfolio could be switched from using `div` tags to something that more accurately describes them as sections of our page. Update the `.tagline`, `.skills` and `.contact` sections to use a more semantic HTML tag.
33+
34+
### Main Content
35+
36+
Our 3 main sections make up the focus of our page. Wrap these three sections (tagline, skills and contact) in an HTML element that gives it the correct focus.
37+
38+
### Footer
39+
40+
Lastly, the element with a class of `footer` isn't the most semantic use of that area either. Luckily HTML 5 has a much better element we can use for footers. Update this element to use the semantically correct tag.

src/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
<div class="header">
1414
<h1>Sergio Cruz</h1>
1515
<h2>Application Developer</h2>
16+
17+
<ul class="nav">
18+
<li><a href="index.html" class="active">Home</a></li>
19+
<li><a href="about.html">About</a></li>
20+
</ul>
1621
</div>
1722

1823
<div class="tagline">

src/main.css

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,22 @@ h1, h2, h3, h4 {
2020
margin: 10px 0 15px;
2121
}
2222

23+
.nav, nav {
24+
display: inline;
25+
list-style: none;
26+
margin: 1em 0;
27+
padding: 0;
28+
}
29+
.nav li, nav li {
30+
display: inline;
31+
margin-right: 1em;
32+
}
33+
2334
p, ul {
2435
margin: 10px 0;
2536
}
2637

27-
ul li {
38+
.skills ul li {
2839
margin-left: 30px;;
2940
}
3041

@@ -46,6 +57,10 @@ a:active {
4657
top: 1px;
4758
}
4859

60+
a.active {
61+
border-bottom: none;
62+
}
63+
4964
.content-wrapper {
5065
line-height: 1.4;
5166
margin: 0 auto;

test/portfolio.spec.js

Lines changed: 46 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -15,117 +15,84 @@ describe('The webpage', () => {
1515
*/
1616
describe('header', () => {
1717
it('should exist @header', () => {
18-
const header = doc.querySelector('.header');
19-
assert.isOk(header, 'We need a `.header` element.');
20-
});
21-
22-
it('should have a non-empty title @h1', () => {
23-
const h1 = doc.querySelector('.header h1');
24-
assert.isOk(h1, 'We need an `h1` element inside `.header`.');
25-
assert.isOk(h1.textContent, 'Our header\'s `h1` element cannot be empty.');
18+
const header = doc.querySelector('header');
19+
assert.isOk(header, 'We need a `header` element.');
2620
});
2721

28-
it('should have a non-empty description @h2', () => {
29-
const h2 = doc.querySelector('.header h2');
30-
assert.isOk(h2, 'We need an `h2` element inside `.header`.');
31-
assert.isOk(h2.textContent, 'Our header\'s `h2` element cannot be empty.');
22+
it('should not exist @header', () => {
23+
const header = doc.querySelector('.header');
24+
assert.isOk(!header, 'Make sure to remote the `.header` class -- we no longer need it.');
3225
});
3326
});
3427

3528

3629
/**
37-
* TAGLINE
30+
* NAV
3831
*/
39-
describe('tagline', () => {
40-
it('should exist @tagline', () => {
41-
const tagline = doc.querySelector('.tagline');
42-
assert.isOk(tagline, 'We need a `.tagline` element.');
32+
describe('nav', () => {
33+
it('should exist @nav', () => {
34+
const nav = doc.querySelector('header nav');
35+
assert.isOk(nav, 'We need a `nav` element inside `header`.');
4336
});
4437

45-
it('should have a non-empty h3 tag @tagline-content', () => {
46-
const h3 = doc.querySelector('.tagline h3');
47-
assert.isOk(h3, 'We need an `h3` element inside `.tagline`.');
48-
assert.isOk(h3.textContent, 'Our tagline\'s `h3` element cannot be empty.');
49-
});
50-
51-
it('should have a descriptive paragraph @tagline-content', () => {
52-
const p = doc.querySelector('.tagline p');
53-
assert.isOk(p, 'We need a `p` element inside `.tagline`.');
54-
assert.isOk(p.textContent, 'Our tagline\'s `p` element cannot be empty.');
38+
it('should remove the existing class @nav', () => {
39+
const nav = doc.querySelector('header .nav');
40+
assert.isOk(!nav, 'We no longer need an element with a class of `.nav`. Go ahead and remove it.');
5541
});
5642
});
5743

5844

5945
/**
60-
* SKILLS
46+
* SECTION
6147
*/
62-
describe('skills', () => {
63-
it('should exist @skills', () => {
64-
const skills = doc.querySelector('.skills');
65-
assert.isOk(skills, 'We need a `.skills` element.');
66-
});
67-
68-
it('should have a non-empty h3 tag @skills-content', () => {
69-
const h3 = doc.querySelector('.skills h3');
70-
assert.isOk(h3, 'We need an `h3` element inside `.skills`.');
71-
assert.isOk(h3.textContent, 'Our skills\' `h3` element cannot be empty.');
48+
describe('section', () => {
49+
it('should convert the tagline @section', () => {
50+
const el = doc.querySelector('.tagline');
51+
assert.isOk(el.length > 0, 'Looks like you removed the element with a class of `.tagline`. You will still need that, but will need to change it\'s element.');
52+
assert.equal(el.tagName.toLowerCase(), 'section', 'Make sure to change the element with a class of `tagline` to a `section` element.');
7253
});
7354

74-
it('should have a descriptive paragraph @skills-content', () => {
75-
const p = doc.querySelector('.skills p');
76-
assert.isOk(p, 'We need a `p` element inside `.skills`.');
77-
assert.isOk(p.textContent, 'Our skills\' `p` element cannot be empty.');
55+
it('should convert the skills @section', () => {
56+
const el = doc.querySelector('.skills');
57+
assert.isOk(el.length > 0, 'Looks like you removed the element with a class of `.skills`. You will still need that, but will need to change it\'s element.');
58+
assert.equal(skillsWithHtml.tagName.toLowerCase(), 'section', 'Make sure to change the element with a class of `skills` to a `section` element.');
7859
});
7960

80-
it('should have an unordered list of your skills @skills-list', () => {
81-
const ul = doc.querySelector('.skills ul');
82-
assert.isOk(ul, 'We need a `ul` element inside `.skills`.');
83-
});
84-
85-
it('should have at least 3 skills @skills-list', () => {
86-
const skillItems = doc.querySelectorAll('.skills ul li');
87-
assert.isAtLeast(skillItems.length, 3, 'We need at least 3 `li` elements inside the skills\' `ul`.');
88-
});
89-
90-
it('should have one skill that contains HTML @skills-list', () => {
91-
const skillItems = Array.from(doc.querySelectorAll('.skills ul li'));
92-
const htmlRegex = /html/i;
93-
94-
const skillsWithHtml = skillItems
95-
.map(li => li.textContent)
96-
.filter(skill => htmlRegex.test(skill));
97-
98-
assert.equal(skillsWithHtml.length, 1, 'HTML needs be part of one of your skills.');
61+
it('should convert the contact @section', () => {
62+
const el = doc.querySelector('.contact');
63+
assert.isOk(el.length > 0, 'Looks like you removed the element with a class of `.contact`. You will still need that, but will need to change it\'s element.');
64+
assert.equal(skillsWithHtml.tagName.toLowerCase(), 'section', 'Make sure to change the element with a class of `contact` to a `section` element.');
9965
});
10066
});
10167

10268

10369
/**
104-
* CONTACT
70+
* MAIN
10571
*/
106-
describe('contact', () => {
107-
it('should exist @contact', () => {
108-
const contact = doc.querySelector('.contact');
109-
assert.isOk(contact, 'We need a `.contact` element.');
72+
describe('main', () => {
73+
it('should exist @main', () => {
74+
const header = doc.querySelector('main');
75+
assert.isOk(header, 'We need a `main` element.');
11076
});
11177

112-
it('should have a non-empty h3 tag @contact-content', () => {
113-
const h3 = doc.querySelector('.contact h3');
114-
assert.isOk(h3, 'We need an `h3` element inside `.contact`.');
115-
assert.isOk(h3.textContent, 'Our contact\'s `h3` element cannot be empty.');
78+
it('should not exist @main', () => {
79+
const sections = doc.querySelector('main section');
80+
assert.isOk(sections.length >= 3, 'Make sure to move all of the `section` elements into our new `main` element.');
11681
});
82+
});
11783

118-
it('should have a descriptive paragraph @contact-content', () => {
119-
const p = doc.querySelector('.contact p');
120-
assert.isOk(p, 'We need a `p` element inside `.contact`.');
121-
assert.isOk(p.textContent, 'Our contact\'s `p` element cannot be empty.');
84+
/**
85+
* FOOTER
86+
*/
87+
describe('footer', () => {
88+
it('should exist @footer', () => {
89+
const footer = doc.querySelector('footer');
90+
assert.isOk(footer, 'We need a `footer` element.');
12291
});
12392

124-
it('should have a link with an href within the paragraph @contact-link', () => {
125-
const a = doc.querySelector('.contact p a');
126-
assert.isOk(a, 'We need a `a` element our inside contact\'s `p` element.');
127-
assert.isOk(a.textContent, 'Our contact\'s `a` element cannot be empty.');
128-
assert.isOk(a.getAttribute('href'), 'Our contact\'s `a` element needs a non-empty `href` attribute.');
93+
it('should not exist @main', () => {
94+
const footer = doc.querySelector('.footer');
95+
assert.isOk(!footer, 'Remove the `footer` class. Since we\'re using semantic HTML, we no longer need that one.');
12996
});
13097
});
13198

0 commit comments

Comments
 (0)