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:
committed by
Facebook GitHub Bot
parent
3e7a6b1b4b
commit
d88b28330a
68
desktop/flipper-common/src/__tests__/clientUtils.node.tsx
Normal file
68
desktop/flipper-common/src/__tests__/clientUtils.node.tsx
Normal 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);
|
||||
});
|
||||
Reference in New Issue
Block a user