-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
42 lines (32 loc) · 1.1 KB
/
index.test.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
var URLBuilder = require('./index.js')
it('should have the correct method', function () {
var builder = new URLBuilder('http://test-url.com')
expect(builder.params).toBeTruthy()
expect(builder.build).toBeTruthy()
})
it('should build the right url', function () {
var expectedURL = 'http://test-url.com?query1=1&query2=2'
var resultURL = new URLBuilder('http://test-url.com')
.params('query1', '1')
.params('query2', '2')
.build()
expect(resultURL).toBe(expectedURL)
})
it('should handle null value correctly', function () {
var expectedURL = 'http://test-url.com?query1=1&query2=2'
var resultURL = new URLBuilder('http://test-url.com')
.params('query1', '1')
.params('query2', '2')
.params('query3', null)
.build()
expect(resultURL).toBe(expectedURL)
})
it('should handle empty string value correctly', function () {
var expectedURL = 'http://test-url.com?query1=1&query2=2'
var resultURL = new URLBuilder('http://test-url.com')
.params('query1', '1')
.params('query2', '2')
.params('query3', '')
.build()
expect(resultURL).toBe(expectedURL)
})