1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { customDecodeURI, customEncodeURI, encodeHash } from './url';
7 describe('url', () => {
8 describe('encodeHash', () => {
9 it('should ignore path without hash', () => {
11 const path = 'path/without/hash';
14 const result = encodeHash(path);
17 expect(result).toEqual(path);
20 it('should replace all hashes within the path', () => {
22 const path = 'path/with/hash # and one more #';
23 const expectedResult = 'path/with/hash %23 and one more %23';
26 const result = encodeHash(path);
29 expect(result).toEqual(expectedResult);
33 describe('customEncodeURI', () => {
34 it('should decode', () => {
36 const path = 'test%23test%2Ftest';
37 const expectedResult = 'test#test/test';
40 const result = customDecodeURI(path);
43 expect(result).toEqual(expectedResult);
47 describe('customEncodeURI', () => {
48 it('should encode', () => {
50 const path = 'test#test/test';
51 const expectedResult = 'test%23test/test';
54 const result = customEncodeURI(path);
57 expect(result).toEqual(expectedResult);