forked from microsoft/CopilotHackathon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
131 lines (112 loc) · 3.74 KB
/
Copy pathtest.js
File metadata and controls
131 lines (112 loc) · 3.74 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//write npm command line to install mocha
//npm install --global mocha
//command to run this test file
//mocha test.js
const assert = require('assert');
const http = require('http');
const server = require('./nodeserver');
describe('Node Server', () => {
it('should return "key not passed" if key is not passed', (done) => {
http
.get('http://localhost:3000/Get' , (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
assert.equal(data, 'key not passed');
done();
});
});
});
it('should return the value of the key if key is found', (done) => {
http.get('http://localhost:3000/Get?key=world', (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
assert.equal(data, 'hello world');
done();
});
});
});
//add test to check validatephoneNumber
it('should return "valid" if phoneNumber is valid', (done) => {
http.get('http://localhost:3000/Validatephonenumber?phoneNumber=34666666666', (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
assert.equal(data, 'valid');
done();
});
});
});
//write test to validate spanish DNI
it('should return "valid" if spanish DNI 86471508H is valid', (done) => {
http.get('http://localhost:3000/ValidateSpanishDNI?dni=86471508H', (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
assert.equal(data, 'valid');
done();
});
});
});
//write test to validate spanish DNI
it('should return "valid" if spanish DNI 24153149K is valid', (done) => {
http.get('http://localhost:3000/ValidateSpanishDNI?dni=24153149K', (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
assert.equal(data, 'valid');
done();
});
});
});
//write test to validate spanish DNI
it('should return "valid" if spanish DNI 12345678A is invalid', (done) => {
http.get('http://localhost:3000/ValidateSpanishDNI?dni=12345678A', (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
assert.equal(data, 'invalid');
done();
});
});
});
//write test for returnColorCode
it('should return "red" if color is red', (done) => {
http.get('http://localhost:3000/ReturnColorCode?color=red', (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
assert.equal(data, '#FF0000');
done();
});
});
});
//write test for daysBetweenDates
it('should return "1" if dates are 2020-01-01 and 2020-01-02', (done) => {
http.get('http://localhost:3000/DaysBetweenDates?date1=2020-01-01&date2=2020-01-02', (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
assert.equal(data, '1 days');
done();
});
});
});
});