projects
/
arvados-workbench2.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
17337: Added more tests to cover edge cases
[arvados-workbench2.git]
/
src
/
common
/
url.test.ts
diff --git
a/src/common/url.test.ts
b/src/common/url.test.ts
index 80181a746ad698650f143bfb41a9f39cbb3177c3..b0f8ae251af7e9a5b054c0cc2cb74ee78d20bbf6 100644
(file)
--- a/
src/common/url.test.ts
+++ b/
src/common/url.test.ts
@@
-30,11
+30,11
@@
describe('url', () => {
});
});
});
});
- describe('custom
En
codeURI', () => {
- it('should decode', () => {
+ describe('custom
De
codeURI', () => {
+ it('should decode
encoded URI
', () => {
// given
const path = 'test%23test%2Ftest';
// given
const path = 'test%23test%2Ftest';
- const expectedResult = 'test#test
/
test';
+ const expectedResult = 'test#test
%2F
test';
// when
const result = customDecodeURI(path);
// when
const result = customDecodeURI(path);
@@
-42,10
+42,21
@@
describe('url', () => {
// then
expect(result).toEqual(expectedResult);
});
// then
expect(result).toEqual(expectedResult);
});
+
+ it('ignores non parsable URI and return its original form', () => {
+ // given
+ const path = 'test/path/with%wrong/sign';
+
+ // when
+ const result = customDecodeURI(path);
+
+ // then
+ expect(result).toEqual(path);
+ });
});
describe('customEncodeURI', () => {
});
describe('customEncodeURI', () => {
- it('should encode', () => {
+ it('should encode
URI
', () => {
// given
const path = 'test#test/test';
const expectedResult = 'test%23test/test';
// given
const path = 'test#test/test';
const expectedResult = 'test%23test/test';
@@
-56,5
+67,16
@@
describe('url', () => {
// then
expect(result).toEqual(expectedResult);
});
// then
expect(result).toEqual(expectedResult);
});
+
+ it('ignores non encodable URI and return its original form', () => {
+ // given
+ const path = 22;
+
+ // when
+ const result = customEncodeURI(path as any);
+
+ // then
+ expect(result).toEqual(path);
+ });
});
});
\ No newline at end of file
});
});
\ No newline at end of file