-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject_fun.js
More file actions
43 lines (38 loc) · 827 Bytes
/
object_fun.js
File metadata and controls
43 lines (38 loc) · 827 Bytes
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
/*
object fun
*/
var expect = require('chai').expect;
function myObject(){
var stack = [];
this.size = function() {
return stack.length;
}
this.push = function() {
for(var i =0; i < arguments.length; i+= 1) {
stack.push(arguments[i]);
}
}
this.pop = function(){
if (stack.length > 0 ) {
return this.stack.pop();
} else {
return null;
}
}
}
describe('myObject', function(){
beforeEach(function(){
o = new myObject();
});
it('size should be zero', function(){
expect( o.size() ).to.be.equal(0);
});
it('size should be 5', function(){
o.push(5);
expect( o.size() ).to.be.equal(1);
});
it('size should be 3', function(){
o.push(5, 2, "wanker");
expect( o.size() ).to.be.equal(3);
});
});