Skip to content

Commit e66921a

Browse files
committed
Updated tests
1 parent fe371cb commit e66921a

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

test/portfolio.spec.js

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ describe('The webpage', () => {
1414
* HEADER
1515
*/
1616
describe('header', () => {
17-
it('should exist', () => {
17+
it('should exist @header', () => {
1818
const header = doc.querySelector('.header');
19-
assert.isOk(header);
19+
assert.isOk(header, 'We need a `.header` element.');
2020
});
2121

22-
it('should have a non-empty title', () => {
22+
it('should have a non-empty title @header', () => {
2323
const h1 = doc.querySelector('.header h1');
24-
assert.isOk(h1);
25-
assert.isOk(h1.textContent);
24+
assert.isOk(h1, 'We need an `h1` element inside `.header`.');
25+
assert.isOk(h1.textContent, 'Our header\'s `h1` element cannot be empty.');
2626
});
2727

28-
it('should have a non-empty description', () => {
28+
it('should have a non-empty description @header', () => {
2929
const h2 = doc.querySelector('.header h2');
30-
assert.isOk(h2);
31-
assert.isOk(h2.textContent);
30+
assert.isOk(h2, 'We need an `h2` element inside `.header`.');
31+
assert.isOk(h2.textContent, 'Our header\'s `h2` element cannot be empty.');
3232
});
3333
});
3434

@@ -37,65 +37,65 @@ describe('The webpage', () => {
3737
* TAGLINE
3838
*/
3939
describe('tagline', () => {
40-
it('should exist', () => {
40+
it('should exist @tagline', () => {
4141
const tagline = doc.querySelector('.tagline');
42-
assert.isOk(tagline);
42+
assert.isOk(tagline, 'We need a `.tagline` element.');
4343
});
4444

45-
it('should have a non-empty h3 tag', () => {
45+
it('should have a non-empty h3 tag @tagline', () => {
4646
const h3 = doc.querySelector('.tagline h3');
47-
assert.isOk(h3);
48-
assert.isOk(h3.textContent);
47+
assert.isOk(h3, 'We need an `h3` element inside `.tagline`.');
48+
assert.isOk(h3.textContent, 'Our tagline\'s `h3` element cannot be empty.');
4949
});
5050

51-
it('should have a descriptive paragraph', () => {
51+
it('should have a descriptive paragraph @tagline', () => {
5252
const p = doc.querySelector('.tagline p');
53-
assert.isOk(p);
54-
assert.isOk(p.textContent);
53+
assert.isOk(p, 'We need a `p` element inside `.tagline`.');
54+
assert.isOk(p.textContent, 'Our tagline\'s `p` element cannot be empty.');
5555
});
5656
});
57-
57+
5858

5959
/**
6060
* SKILLS
6161
*/
6262
describe('skills', () => {
63-
it('should exist', () => {
63+
it('should exist @skills', () => {
6464
const skills = doc.querySelector('.skills');
65-
assert.isOk(skills);
65+
assert.isOk(skills, 'We need a `.skills` element.');
6666
});
6767

68-
it('should have a non-empty h3 tag', () => {
68+
it('should have a non-empty h3 tag @skills', () => {
6969
const h3 = doc.querySelector('.skills h3');
70-
assert.isOk(h3);
71-
assert.isOk(h3.textContent);
70+
assert.isOk(h3, 'We need an `h3` element inside `.skills`.');
71+
assert.isOk(h3.textContent, 'Our skills\' `h3` element cannot be empty.');
7272
});
7373

74-
it('should have a descriptive paragraph', () => {
74+
it('should have a descriptive paragraph @skills', () => {
7575
const p = doc.querySelector('.skills p');
76-
assert.isOk(p);
77-
assert.isOk(p.textContent);
76+
assert.isOk(p, 'We need a `p` element inside `.skills`.');
77+
assert.isOk(p.textContent, 'Our skills\' `p` element cannot be empty.');
7878
});
7979

80-
it('should have an unordered list of your skills', () => {
80+
it('should have an unordered list of your skills @skills', () => {
8181
const ul = doc.querySelector('.skills ul');
82-
assert.isOk(ul);
82+
assert.isOk(ul, 'We need a `ul` element inside `.skills`.');
8383
});
8484

85-
it('should have at least 3 skills', () => {
85+
it('should have at least 3 skills @skills', () => {
8686
const skillItems = doc.querySelectorAll('.skills ul li');
87-
assert.isAtLeast(skillItems.length, 3);
87+
assert.isAtLeast(skillItems.length, 3, 'We need at least 3 `li` elements inside the skills\' `ul`.');
8888
});
8989

90-
it('should have one skill that contains HTML', () => {
90+
it('should have one skill that contains HTML @skills', () => {
9191
const skillItems = Array.from(doc.querySelectorAll('.skills ul li'));
9292
const htmlRegex = /html/i;
9393

9494
const skillsWithHtml = skillItems
9595
.map(li => li.textContent)
9696
.filter(skill => htmlRegex.test(skill));
9797

98-
assert.equal(skillsWithHtml.length, 1);
98+
assert.equal(skillsWithHtml.length, 1, 'HTML needs be part of one of your skills.');
9999
});
100100
});
101101

@@ -104,28 +104,28 @@ describe('The webpage', () => {
104104
* CONTACT
105105
*/
106106
describe('contact', () => {
107-
it('should exist', () => {
107+
it('should exist @contact', () => {
108108
const contact = doc.querySelector('.contact');
109-
assert.isOk(contact);
109+
assert.isOk(contact, 'We need a `.contact` element.');
110110
});
111111

112-
it('should have a non-empty h3 tag', () => {
112+
it('should have a non-empty h3 tag @contact', () => {
113113
const h3 = doc.querySelector('.contact h3');
114-
assert.isOk(h3);
115-
assert.isOk(h3.textContent);
114+
assert.isOk(h3, 'We need an `h3` element inside `.contact`.');
115+
assert.isOk(h3.textContent, 'Our contact\'s `h3` element cannot be empty.');
116116
});
117117

118-
it('should have a descriptive paragraph', () => {
118+
it('should have a descriptive paragraph @contact', () => {
119119
const p = doc.querySelector('.contact p');
120-
assert.isOk(p);
121-
assert.isOk(p.textContent);
120+
assert.isOk(p, 'We need a `p` element inside `.contact`.');
121+
assert.isOk(p.textContent, 'Our contact\'s `p` element cannot be empty.');
122122
});
123123

124-
it('should have a link with an href within the paragraph', () => {
124+
it('should have a link with an href within the paragraph @contact', () => {
125125
const a = doc.querySelector('.contact p a');
126-
assert.isOk(a);
127-
assert.isOk(a.textContent);
128-
assert.isOk(a.getAttribute('href'));
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.');
129129
});
130130
});
131131

0 commit comments

Comments
 (0)