-
Notifications
You must be signed in to change notification settings - Fork 884
Expand file tree
/
Copy pathlibrary-test.js
More file actions
69 lines (53 loc) · 2.41 KB
/
library-test.js
File metadata and controls
69 lines (53 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var { issueCard, searchByAuthor } = require('./library');
var assert = require('chai').assert;
describe('Library', function() {
it.skip('should issue a library card', function() {
var card = issueCard('George', 32);
assert.equal(card.name, 'George');
assert.equal(card.age, 32);
assert.equal(card.numBooksCheckedOut, 0);
});
it.skip('should issue a card and check if it belongs to a child younger than 12 years old', function() {
var card = issueCard('George', 32);
assert.equal(card.name, 'George');
assert.equal(card.age, 32);
assert.equal(card.numBooksCheckedOut, 0);
assert.equal(card.isChild, false);
var childCard = issueCard('Kim', 10);
assert.equal(childCard.name, 'Kim');
assert.equal(childCard.age, 10);
assert.equal(childCard.numBooksCheckedOut, 0);
assert.equal(childCard.isChild, true);
});
it.skip('should be able to search through a catalog by author and return book result', function() {
var collection = [
{title: 'My Life', author: 'Alex', status: 'on shelf'},
{title: 'Adventures', author: 'Sam', status: 'checked out'},
{title: 'Cooking Food', author: 'Jamie', status: 'on shelf'}
]
var searchResults = searchByAuthor(collection, 'Sam');
assert.deepEqual(searchResults, [{title: 'Adventures', author: 'Sam', status: 'checked out'}]);
});
it.skip('should be able to handle a search with multiple results', function() {
var collection = [
{title: 'My Life', author: 'Alex', status: 'on shelf'},
{title: 'Adventures', author: 'Sam', status: 'checked out'},
{title: 'Cooking Food', author: 'Jamie', status: 'on shelf'},
{title: 'Cooking Spicy Things', author: 'Jamie', status: 'on shelf'}
]
var searchResult = searchByAuthor(collection, 'Jamie');
assert.deepEqual(searchResult, [
{title: 'Cooking Food', author: 'Jamie', status: 'on shelf'},
{title: 'Cooking Spicy Things', author: 'Jamie', status: 'on shelf'}
]);
});
it.skip('should be able to handle a search with no results', function() {
var collection = [
{title: 'My Life', author: 'Alex', status: 'on shelf'},
{title: 'Adventures', author: 'Sam', status: 'checked out'},
{title: 'Cooking Things', author: 'Jamie', status: 'on shelf'}
]
var searchResult = searchByAuthor(collection, 'Vicky');
assert.equal(searchResult, 'No book found for search criteria');
});
});