Summary: This gets us on the latest Prettier 2.x: https://prettier.io/blog/2020/03/21/2.0.0.html Notably, this adds support for TypeScript 3.8, which introduces new syntax, such as `import type`. Reviewed By: zertosh Differential Revision: D20636268 fbshipit-source-id: fca5833d003804333a05ba16325bbbe0e06d6c8a
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
import JsonFileStorage from '../jsonFileReduxPersistStorage.tsx';
|
|
import fs from 'fs';
|
|
|
|
const validSerializedData = fs
|
|
.readFileSync('app/src/utils/__tests__/data/settings-v1-valid.json')
|
|
.toString()
|
|
.replace(/\r\n/g, '\n')
|
|
.trim();
|
|
|
|
const validDeserializedData =
|
|
'{"androidHome":"\\"/opt/android_sdk\\"","something":"{\\"else\\":4}","_persist":"{\\"version\\":-1,\\"rehydrated\\":true}"}';
|
|
|
|
const storage = new JsonFileStorage(
|
|
'app/src/utils/__tests__/data/settings-v1-valid.json',
|
|
);
|
|
|
|
test('A valid settings file gets parsed correctly', () => {
|
|
return storage
|
|
.getItem('anykey')
|
|
.then(result => expect(result).toEqual(validDeserializedData));
|
|
});
|
|
|
|
test('deserialize works as expected', () => {
|
|
const deserialized = storage.deserializeValue(validSerializedData);
|
|
expect(deserialized).toEqual(validDeserializedData);
|
|
});
|
|
|
|
test('serialize works as expected', () => {
|
|
const serialized = storage.serializeValue(validDeserializedData);
|
|
expect(serialized).toEqual(validSerializedData);
|
|
});
|