datahub/datahub-web/@datahub/utils/tests/unit/api/encode-decode-uri-component-with-space-test.ts
Charlie Tran 843a6c5bbb
feat(frontend): update datahub-web client UI code (#1806)
* Releases updated version of datahub-web client UI code

* Fix typo in yarn lock

* Change yarn lock to match yarn registry directories

* Previous commit missed some paths

* Even more changes to yarnlock missing in previous commit

* Include codegen file for typings

* Add files to get parity for datahub-web and current OS datahub-midtier

* Add in typo fix from previous commit - change to proper license

* Implement proper OS fix for person entity picture url

* Workarounds for open source DH issues

* Fixes institutional memory api and removes unopensourced tabs for datasets

* Fixes search dataset deprecation and user search issue as a result of changes

* Remove internal only options in the avatar menu
2020-08-26 15:44:50 -07:00

28 lines
1.2 KiB
TypeScript

import { encode, decode } from '@datahub/utils/api/encode-decode-uri-component-with-space';
import { module, test } from 'qunit';
module('Unit | Utility | encode decode uri component with space', function(): void {
const unEncodedAlphaNumericWithSpace = 'ABC 123 with space';
const decodedAlphaNumericWithSpace = 'ABC+123+with+space';
const reservedChars = "Aa0-_.!~*'()";
test('encode function', function(assert): void {
let result = encode(unEncodedAlphaNumericWithSpace);
assert.ok(typeof result === 'string', 'encode returns a value');
assert.notOk(/%20/.test(result), 'result does not contain %20 replacement for space');
assert.equal(result, decodedAlphaNumericWithSpace, 'result is encoded as expected');
result = encode(reservedChars);
assert.equal(reservedChars, result, 'reserved characters should be untouched');
});
test('decode function', function(assert): void {
const result = decode(decodedAlphaNumericWithSpace);
assert.ok(typeof result === 'string', 'encode returns a value');
assert.notOk(/\+/.test(result), 'result does not contain + replacement for space');
assert.equal(result, unEncodedAlphaNumericWithSpace, 'result is decoded as expected');
});
});