Skip to content

Commit e54c935

Browse files
author
Kent C. Dodds
committed
write tests 📝
1 parent 0208c5b commit e54c935

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/index.test.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
'use strict';
22

33
var expect = require('chai').expect;
4+
var starWarsNames = require('.');
45

56
describe('starwars-names', function() {
6-
it('should work', function() {
7-
expect(true).to.be.true
7+
it('should have a list of all available names', function() {
8+
expect(starWarsNames.all).to.satisfy(isArrayOfStrings);
9+
});
10+
11+
it('should allow me to get a random name from the list', function() {
12+
expect(starWarsNames.random()).to.satisfy(isIncludedIn(starWarsNames.all));
813
});
914
});
15+
16+
function isArrayOfStrings(array) {
17+
return array.every(function(i) {
18+
return typeof i === 'string';
19+
});
20+
}
21+
22+
function isIncludedIn(array) {
23+
return function(item) {
24+
return array.includes(item);
25+
};
26+
}

0 commit comments

Comments
 (0)