projects
/
arvados-workbench2.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
17914: Replaces deprecated substr() with substring().
[arvados-workbench2.git]
/
src
/
common
/
url.test.ts
diff --git
a/src/common/url.test.ts
b/src/common/url.test.ts
index 4753096647bb92952c68678f3a92a6e3a5d63022..21bc518ce1f8c687a15fc9320d76c28565c09af6 100644
(file)
--- a/
src/common/url.test.ts
+++ b/
src/common/url.test.ts
@@
-2,59
+2,56
@@
//
// SPDX-License-Identifier: AGPL-3.0
//
// SPDX-License-Identifier: AGPL-3.0
-import { customDecodeURI, customEncodeURI
, encodeHash
} from './url';
+import { customDecodeURI, customEncodeURI } from './url';
describe('url', () => {
describe('url', () => {
- describe('
encodeHash
', () => {
- it('should
ignore path without hash
', () => {
+ describe('
customDecodeURI
', () => {
+ it('should
decode encoded URI
', () => {
// given
// given
- const path = 'path/without/hash';
+ const path = 'test%23test%2Ftest';
+ const expectedResult = 'test#test%2Ftest';
// when
// when
- const result =
encodeHash
(path);
+ const result =
customDecodeURI
(path);
// then
// then
- expect(result).toEqual(
path
);
+ expect(result).toEqual(
expectedResult
);
});
});
- it('
should replace all hashes within the path
', () => {
+ it('
ignores non parsable URI and return its original form
', () => {
// given
// given
- const path = 'path/with/hash # and one more #';
- const expectedResult = 'path/with/hash %23 and one more %23';
+ const path = 'test/path/with%wrong/sign';
// when
// when
- const result =
encodeHash
(path);
+ const result =
customDecodeURI
(path);
// then
// then
- expect(result).toEqual(
expectedResult
);
+ expect(result).toEqual(
path
);
});
});
describe('customEncodeURI', () => {
});
});
describe('customEncodeURI', () => {
- it('should
decode
', () => {
+ it('should
encode URI
', () => {
// given
// given
- const path = 'test
%23test%2F
test';
- const expectedResult = 'test
#
test/test';
+ const path = 'test
#test/
test';
+ const expectedResult = 'test
%23
test/test';
// when
// when
- const result = custom
De
codeURI(path);
+ const result = custom
En
codeURI(path);
// then
expect(result).toEqual(expectedResult);
});
// then
expect(result).toEqual(expectedResult);
});
- });
- describe('customEncodeURI', () => {
- it('should encode', () => {
+ it('ignores non encodable URI and return its original form', () => {
// given
// given
- const path = 'test#test/test';
- const expectedResult = 'test%23test%2Ftest';
+ const path = 22;
// when
// when
- const result = customEncodeURI(path);
+ const result = customEncodeURI(path
as any
);
// then
// then
- expect(result).toEqual(
expectedResult
);
+ expect(result).toEqual(
path
);
});
});
});
\ No newline at end of file
});
});
});
\ No newline at end of file