Skip to content

Commit dd76840

Browse files
committed
remove redundant string test, add browser test for non-base64 string
1 parent 15a2e85 commit dd76840

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

packages/browser/test/unit/string.test.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,11 @@ describe('base64ToUnicode/unicodeToBase64', () => {
1717
expect(BASE64_REGEX.test(unicodeToBase64(unicodeString))).to.be.true;
1818
});
1919

20-
it('works as expected', () => {
20+
it('works as expected (and conversion functions are inverses)', () => {
2121
expect(unicodeToBase64(unicodeString)).to.equal(base64String);
2222
expect(base64ToUnicode(base64String)).to.equal(unicodeString);
2323
});
2424

25-
it('conversion functions are inverses', () => {
26-
expect(base64ToUnicode(unicodeToBase64(unicodeString))).to.equal(unicodeString);
27-
expect(unicodeToBase64(base64ToUnicode(base64String))).to.equal(base64String);
28-
});
29-
3025
it('can handle and preserve multi-byte characters in original string', () => {
3126
['🐶', 'Καλό κορίτσι, Μάιζεϊ!', 'Of margir hundar! Ég geri ráð fyrir að ég þurfi stærra rúm.'].forEach(orig => {
3227
expect(() => {
@@ -56,9 +51,9 @@ describe('base64ToUnicode/unicodeToBase64', () => {
5651
expect(() => {
5752
base64ToUnicode({} as any);
5853
}).to.throw('Unable to convert from base64');
59-
60-
// Note that by design, in node base64 encoding and decoding will accept any string, whether or not it's valid
61-
// base64, by ignoring all invalid characters, including whitespace. Therefore, no wacky strings have been included
62-
// here because they don't actually error.
54+
expect(() => {
55+
// the exclamation point makes this invalid base64
56+
base64ToUnicode('Dogs are great!');
57+
}).to.throw('Unable to convert from base64');
6358
});
6459
});

packages/utils/test/string.test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,11 @@ describe('base64ToUnicode/unicodeToBase64', () => {
6161
expect(BASE64_REGEX.test(unicodeToBase64(unicodeString))).toBe(true);
6262
});
6363

64-
test('works as expected', () => {
64+
test('works as expected (and conversion functions are inverses)', () => {
6565
expect(unicodeToBase64(unicodeString)).toEqual(base64String);
6666
expect(base64ToUnicode(base64String)).toEqual(unicodeString);
6767
});
6868

69-
test('conversion functions are inverses', () => {
70-
expect(base64ToUnicode(unicodeToBase64(unicodeString))).toEqual(unicodeString);
71-
expect(unicodeToBase64(base64ToUnicode(base64String))).toEqual(base64String);
72-
});
73-
7469
test('can handle and preserve multi-byte characters in original string', () => {
7570
['🐶', 'Καλό κορίτσι, Μάιζεϊ!', 'Of margir hundar! Ég geri ráð fyrir að ég þurfi stærra rúm.'].forEach(orig => {
7671
expect(() => {

0 commit comments

Comments
 (0)