Files
flipper/desktop/flipper-plugin/src/ui/__tests__/NUX.node.tsx
Michel Weststrate f5f9608098 Remove crypto dependency
Summary:
Remove crypto dep, which was only used by NUX, to hash the elements that has been confirmed.

Sadly trickier than hoped; there is no uniform api in both browser and Node available that can take a sha-256 hash, and the browser APIs are async.

Reviewed By: aigoncharov

Differential Revision: D32721204

fbshipit-source-id: 32625f83bf6c60cedc4fb7096240c2fa0d8434a7
2021-12-08 04:30:56 -08:00

44 lines
1.1 KiB
TypeScript

/**
* 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 {TestUtils} from '../../';
import React from 'react';
import {getNuxKey} from '../NUX';
test('nuxkey computation', async () => {
// Not a very good test, as our hashing api's are not available in Node...
expect(await getNuxKey('test')).toMatchInlineSnapshot(`"flipper:test"`);
expect(await getNuxKey('test2')).toMatchInlineSnapshot(`"flipper:test2"`);
expect(await getNuxKey(<div>bla</div>)).toMatchInlineSnapshot(`
"flipper:<div>
bla
</div>"
`);
expect(await getNuxKey(<div>bla2</div>)).toMatchInlineSnapshot(`
"flipper:<div>
bla2
</div>"
`);
});
test('nuxkey computation with plugin', async () => {
const res = TestUtils.startPlugin({
Component() {
return null;
},
plugin() {
return {};
},
});
expect(
await getNuxKey('test', (res as any)._backingInstance),
).toMatchInlineSnapshot(`"TestPlugin:test"`);
});