-
Notifications
You must be signed in to change notification settings - Fork 291
/
TestSpec.js
executable file
·100 lines (83 loc) · 2.38 KB
/
TestSpec.js
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
describe('jasmine-node-flat', function(){
it('should pass', function(){
expect(1+2).toEqual(3);
});
});
describe('beforeEach Timeout', function(){
beforeEach(function(done) {
setTimeout(done, 1000);
}, 100);
it('should fail', function(){
expect(1+2).toEqual(3);
});
});
describe('afterEach Timeout', function(){
afterEach(function(done) {
setTimeout(done, 1000);
}, 100);
it('should pass and then afterEach will fail', function(){
expect(1+2).toEqual(3);
});
});
describe('Testing some characters', function() {
var chars = ['&', '\'', '"', '<', '>'];
for(var i = 0; i < chars.length; i+=1) {
currentChar = chars[i];
it('should reject ' + currentChar, (function(currentChar) {
expect(false).toEqual(false);
})(currentChar));
}
});
describe('Testing waitsfor functionality', function() {
it("Runs and then waitsFor", function() {
runs(function() {
1+1;
});
waitsFor(function() {
return true === false;
}, "the impossible", 1000);
runs(function() {
expect(true).toBeTruthy();
});
});
});
describe('root', function () {
describe('nested', function () {
xit('nested statement', function () {
expect(1).toBeTruthy();
});
});
it('root statement', function () {
expect(1).toBeTruthy();
});
});
describe("Top level describe block", function() {
it("first it block in top level describe", function() {
expect(true).toEqual(true);
});
describe("Second level describe block", function() {
it("first it block in second level describe", function() {
expect(true).toBe(true);
});
});
it("second it block in top level describe", function() {
expect(true).toEqual(true);
});
});
describe('async', function () {
var request = function (str, func) {
func('1', '2', 'hello world');
};
it("should respond with hello world", function(done) {
request("http://localhost:3000/hello", function(error, response, body){
expect(body).toEqual("hello world");
done();
});
});
it("should respond with hello world", function(done) {
request("http://localhost:3000/hello", function(error, response, body){
expect(body).toEqual("hello world");
done();
});
}, 250); // timeout after 250 ms
});