Skip to content

Commit 36b0543

Browse files
committed
refactor tests
1 parent 0ec74a0 commit 36b0543

File tree

2 files changed

+31
-24
lines changed

2 files changed

+31
-24
lines changed

fundamentals.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
// #1: Create an array of strings called `foods` that contains three foods.
44
// Type your solution immediately below this line:
55

6-
var foods = ["pizza","pineapple","scrap metal"]
6+
77

88
// #2: Access the last item in the array and assign to a variable called `last`.
99
// Type your solution immediately below this line:
1010

1111

1212

13-
// #3: Create an empty array called `favoriteColors`.
13+
// #3: Create an empty array called `favoriteFoods`.
1414
// Type your solution immediately below this line:
1515

1616

1717

18-
// #4: Create a `for` loop that adds each string in `colors` to `favoriteColors`.
18+
// #4: Create a `for` loop that adds each string in `foods` to `favoriteFoods`.
1919
// Type your solution immediately below this line:
2020

2121

@@ -25,7 +25,7 @@ var foods = ["pizza","pineapple","scrap metal"]
2525

2626

2727

28-
// #6: Add a `facial-hair` (spelled exactly) property to `instructor` by accessing
28+
// #6: Add a `has-office-hours` (spelled exactly) property to `instructor` by accessing
2929
// it (do not change the original object you typed above) and assigning it
3030
// a boolean value.
3131
// Type your solution immediately below this line:

test/fundamentals_test.js

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ describe('Fundamentals #1', function() {
1414
catch(e) {
1515
console.log(e)
1616
}
17-
it('colors is an array', function() {
18-
expect(colors).to.be.an('array')
17+
it('foods is an array', function() {
18+
expect(foods).to.be.an('array')
1919
})
20-
it('colors contains three colors', function() {
21-
expect(colors.length).to.equal(3)
20+
it('foods contains three strings', function() {
21+
expect(foods.length).to.equal(3)
22+
expect(foods.every(food => food.constructor === String)).to.equal(true)
2223
})
2324
})
2425

@@ -36,8 +37,8 @@ describe('Fundamentals #2', function() {
3637
it('last is a string', function() {
3738
expect(last).to.be.a('string')
3839
})
39-
it('last is equal to the last item in colors', function() {
40-
expect(last).to.equal(colors[2])
40+
it('last is equal to the last item in foods', function() {
41+
expect(last).to.equal(foods[2])
4142
})
4243
})
4344

@@ -52,11 +53,11 @@ describe('Fundamentals #3', function() {
5253
catch(e) {
5354
console.log(e)
5455
}
55-
it('favoriteColors is defined', function() {
56-
expect(favoriteColors).to.be.not.undefined
56+
it('favoriteFoods is defined', function() {
57+
expect(favoriteFoods).to.be.not.undefined
5758
})
58-
it('favoriteColors is an array', function() {
59-
expect(favoriteColors).to.be.an('array')
59+
it('favoriteFoods is an array', function() {
60+
expect(favoriteFoods).to.be.an('array')
6061
})
6162
})
6263

@@ -77,14 +78,14 @@ describe('Fundamentals #4', function() {
7778
catch(e) {
7879
console.log(e)
7980
}
80-
it('favoriteColors contains three colors', function() {
81-
expect(favoriteColors.length).to.equal(3)
81+
it('favoriteFoods contains three foods', function() {
82+
expect(favoriteFoods.length).to.equal(3)
8283
})
83-
it('favoriteColors contains the same values as colors', function() {
84+
it('favoriteFoods contains the same values as foods', function() {
8485
expect(
85-
favoriteColors.reduce((a, b) => a + b)
86+
favoriteFoods.reduce((a, b) => a + b)
8687
).to.equal(
87-
colors.reduce((a, b) => a + b)
88+
foods.reduce((a, b) => a + b)
8889
)
8990
})
9091
})
@@ -104,7 +105,10 @@ describe('Fundamentals #5', function() {
104105
expect(instructor).to.be.an('object')
105106
})
106107
it('instructor has three key-value pairs', function() {
107-
expect(Object.keys(instructor).length).to.be.greaterThan(2)
108+
expect(Object.keys(instructor)).to.have.lengthOf(3)
109+
})
110+
it('instructor does not have a \'has-office-hours\' property', function() {
111+
expect(instructor).to.not.have.any.keys('has-office-hours')
108112
})
109113
})
110114

@@ -118,10 +122,13 @@ describe('Fundamentals #6', function() {
118122
catch(e) {
119123
console.log(e)
120124
}
121-
it('instructor has a facial-hair property', function() {
122-
expect(Object.keys(instructor)).to.include('facial-hair')
125+
it('instructor has four key-value pairs', function() {
126+
expect(Object.keys(instructor).length).to.be.equal(4)
127+
})
128+
it('instructor has a has-office-hours property', function() {
129+
expect(instructor).to.have.property('has-office-hours')
123130
})
124-
it('facial-hair has a boolean value', function() {
125-
expect(instructor['facial-hair']).to.be.a('boolean')
131+
it('has-office-hours has a boolean value', function() {
132+
expect(instructor).property('has-office-hours').to.be.a('boolean')
126133
})
127134
})

0 commit comments

Comments
 (0)