Move app/server to flipper-server-core

Summary: moved `app/src/server` to `flipper-server-core/src` and fixed any fallout from that (aka integration points I missed on the preparing diffs).

Reviewed By: passy

Differential Revision: D31541378

fbshipit-source-id: 8a7e0169ebefa515781f6e5e0f7b926415d4b7e9
This commit is contained in:
Michel Weststrate
2021-10-12 15:59:44 -07:00
committed by Facebook GitHub Bot
parent 3e7a6b1b4b
commit d88b28330a
73 changed files with 563 additions and 534 deletions

View File

@@ -0,0 +1,68 @@
/**
* 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 {deconstructClientId, buildClientId} from '../clientUtils';
test('client id constructed correctly', () => {
const consoleErrorSpy = jest.spyOn(global.console, 'error');
const clientId = buildClientId({
app: 'Instagram',
os: 'iOS',
device: 'iPhone Simulator',
device_id: 'EC431B79-69F1-4705-9FE5-9AE5D96378E1',
});
expect(clientId).toBe(
'Instagram#iOS#iPhone Simulator#EC431B79-69F1-4705-9FE5-9AE5D96378E1',
);
expect(consoleErrorSpy).toHaveBeenCalledTimes(0);
});
test('client id deconstructed correctly', () => {
const deconstructedClientId = deconstructClientId(
'Instagram#iOS#iPhone Simulator#EC431B79-69F1-4705-9FE5-9AE5D96378E1',
);
expect(deconstructedClientId).toStrictEqual({
app: 'Instagram',
os: 'iOS',
device: 'iPhone Simulator',
device_id: 'EC431B79-69F1-4705-9FE5-9AE5D96378E1',
});
});
test('client id deconstruction error logged', () => {
const consoleErrorSpy = jest.spyOn(global.console, 'error');
const deconstructedClientId = deconstructClientId(
'Instagram#iPhone Simulator#EC431B79-69F1-4705-9FE5-9AE5D96378E1',
);
expect(deconstructedClientId).toStrictEqual({
app: 'Instagram',
os: 'iPhone Simulator',
device: 'EC431B79-69F1-4705-9FE5-9AE5D96378E1',
device_id: undefined,
});
expect(consoleErrorSpy).toHaveBeenCalledTimes(1);
});
test('special characters in app name handled correctly', () => {
const consoleErrorSpy = jest.spyOn(global.console, 'error');
const testClient = {
app: '#myGreat#App&',
os: 'iOS',
device: 'iPhone Simulator',
device_id: 'EC431B79-69F1-4705-9FE5-9AE5D96378E1',
};
const clientId = buildClientId(testClient);
const deconstructedClientId = deconstructClientId(clientId);
expect(deconstructedClientId).toStrictEqual(testClient);
expect(consoleErrorSpy).toHaveBeenCalledTimes(0);
});