-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from Typeform/fix-responses-after
Fix: parameters in requests
- Loading branch information
Showing
12 changed files
with
147 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { buildUrlWithParams } from '../../src/utils' | ||
|
||
test('the url reminds the same if no parameter passed', () => { | ||
const url = 'http://typeform.com' | ||
expect(buildUrlWithParams(url)).toBe(url) | ||
}) | ||
|
||
test('the url has a query string if parameters are passed', () => { | ||
const url = 'http://typeform.com' | ||
const params = { | ||
a: '1', | ||
b: '2' | ||
} | ||
expect(buildUrlWithParams(url, params)).toBe('http://typeform.com?a=1&b=2') | ||
}) | ||
|
||
test('parameters should be enconded', () => { | ||
const url = 'http://typeform.com' | ||
const params = { | ||
a: '@1', | ||
b: '#2' | ||
} | ||
expect(buildUrlWithParams(url, params)).toBe('http://typeform.com?a=%401&b=%232') | ||
}) | ||
|
||
test('undefined values for parameter will be skipped', () => { | ||
const url = 'http://typeform.com' | ||
const params = { | ||
a: '@1', | ||
b: undefined | ||
} | ||
expect(buildUrlWithParams(url, params)).toBe('http://typeform.com?a=%401') | ||
}) | ||
|
||
test('falsy values should be passed', () => { | ||
const url = 'http://typeform.com' | ||
const params = { | ||
a: '0', | ||
b: 0, | ||
c: null | ||
} | ||
expect(buildUrlWithParams(url, params)).toBe('http://typeform.com?a=0&b=0') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters