Prevent tests with invalid UTF-8 from failing when jest reads them from the cache
Summary: The utf-8 test was failing when run from Jest’s cache, because it contained unicode escape sequences for stray high and low surrogates. Somewhere in the process of transpiling, caching on disk, and reading from the cache, those stray surrogates are changed to U+FFFD (REPLACEMENT CHARACTER / �). This diffs changes the method of creating these strings from literals to `String.fromCharCode`, which survives the process as intended. Reviewed By: bestander Differential Revision: D3534711 fbshipit-source-id: 365bace77a1f914e6e2fbb3430b3e0ea6cec5e83
This commit is contained in:
parent
39cb110c5b
commit
2426b3b5ec
|
@ -50,13 +50,13 @@
|
|||
});
|
||||
|
||||
it('allows for stray high surrogates', () => {
|
||||
const arrayBuffer = encode('a\ud8c6b');
|
||||
const arrayBuffer = encode(String.fromCharCode(0x61, 0xd8c6, 0x62));
|
||||
expect(new Uint8Array(arrayBuffer)).toEqual(
|
||||
new Uint8Array([0x61, 0xed, 0xa3, 0x86, 0x62]));
|
||||
});
|
||||
|
||||
it('allows for stray low surrogates', () => {
|
||||
const arrayBuffer = encode('a\ude19b');
|
||||
const arrayBuffer = encode(String.fromCharCode(0x61, 0xde19, 0x62));
|
||||
expect(new Uint8Array(arrayBuffer)).toEqual(
|
||||
new Uint8Array([0x61, 0xed, 0xb8, 0x99, 0x62]));
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue