forked from bhoop77/JavaScript-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject_test.js
More file actions
82 lines (63 loc) · 2.53 KB
/
Copy pathobject_test.js
File metadata and controls
82 lines (63 loc) · 2.53 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
70
71
72
73
74
75
76
77
78
79
80
81
82
var assert = require('chai').assert;
var myLib = require('../index.js').myLib;
describe('MyLib', function() {
it('should be an object', function () {
assert.equal(typeof(myLib), 'object');
});
it('should have a property called assert that is an object', function() {
assert.equal(typeof(myLib.assert), 'object');
});
it('should have a property called test that is an object', function() {
assert.equal(typeof(myLib.test), 'object');
});
it('should have a property called run that is a function', function() {
assert.equal(typeof(myLib.run), 'function');
});
describe('assert', function() {
it('should have a property called equal that is a function', function() {
assert.equal(typeof(myLib.assert.equal), 'function');
});
describe('equal', function() {
it('should take two parameters and return whether they are equal or not', function() {
assert.equal(true, myLib.assert.equal(5, 5));
});
it('should take two parameters and return whether they are exactly equal or not', function() {
assert.equal(false, myLib.assert.equal(5, '5'));
});
});
});
describe('getBodyContent', function() {
it('should be a function', function() {
assert.equal(typeof(myLib.getBodyContent), 'function');
});
it('should get the HTML of a URL and only return the contents of the <body> tag', function(done) {
var firstCB = function(bodyContent) {
assert.equal('Hello World', bodyContent);
done();
};
myLib.getBodyContent('https://www.google.com/', firstCB);
});
});
describe('getFileContent', function() {
it('should be a function', function() {
assert.equal(typeof(myLib.getFileContent), 'function');
});
it('should get the contents of a file and return it', function(done) {
myLib.getFileContent('testFile.txt', function(content) {
assert.equal('Hello World!', content);
done();
});
});
});
describe('fib', function() {
it('should return the fibonacci number for the provided number', function() {
assert.equal(1, myLib.fib(1));
assert.equal(1, myLib.fib(2));
assert.equal(2, myLib.fib(3));
assert.equal(3, myLib.fib(4));
assert.equal(5, myLib.fib(5));
assert.equal(8, myLib.fib(6));
assert.equal(610, myLib.fib(15));
});
});
});