2021-07-20 22:27:41 +00:00
|
|
|
import { base64DecodeString, base64EncodeString } from 'nomad-ui/utils/encode';
|
|
|
|
import { module, test } from 'qunit';
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
module('Unit | Utility | encode', function () {
|
|
|
|
test('it encodes a null input', function (assert) {
|
2021-07-20 22:27:41 +00:00
|
|
|
const encoded = base64EncodeString(null);
|
|
|
|
const decoded = base64DecodeString(encoded);
|
|
|
|
|
|
|
|
assert.equal(decoded, '');
|
|
|
|
});
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
test('it encodes an empty string', function (assert) {
|
2021-07-20 22:27:41 +00:00
|
|
|
const input = '';
|
|
|
|
const encoded = base64EncodeString(input);
|
|
|
|
const decoded = base64DecodeString(encoded);
|
|
|
|
|
|
|
|
assert.equal(decoded, input);
|
|
|
|
});
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
test('it decodes a null input', function (assert) {
|
2021-07-20 22:27:41 +00:00
|
|
|
const decoded = base64DecodeString(null);
|
|
|
|
|
|
|
|
assert.equal(decoded, '');
|
|
|
|
});
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
test('it decodes an empty string', function (assert) {
|
2021-07-20 22:27:41 +00:00
|
|
|
const decoded = base64DecodeString('');
|
|
|
|
|
|
|
|
assert.equal(decoded, '');
|
|
|
|
});
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
test('it encodes and decodes non-ascii with base64', function (assert) {
|
2021-07-20 22:27:41 +00:00
|
|
|
const input = 'hello 🥳';
|
|
|
|
const encoded = base64EncodeString(input);
|
|
|
|
const decoded = base64DecodeString(encoded);
|
|
|
|
|
|
|
|
assert.equal(decoded, input);
|
|
|
|
});
|
|
|
|
});
|