本文整理汇总了TypeScript中react-cosmos-shared2/util.uuid函数的典型用法代码示例。如果您正苦于以下问题:TypeScript uuid函数的具体用法?TypeScript uuid怎么用?TypeScript uuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uuid函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getRendererId
// Renderer ID is remembered to avoid announcing a new renderer when reloading
// the renderer window. Note that each tab has creates a new session and thus
// a new rendererId.
// https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
function getRendererId(): RendererId {
let rId = sessionStorage.getItem('cosmosRendererId');
if (!rId) {
rId = uuid();
sessionStorage.setItem('cosmosRendererId', rId);
}
return rId;
}
示例2: uuid
import { uuid } from 'react-cosmos-shared2/util';
import retry from '@skidding/async-retry';
import { runFixtureLoaderTests } from '../testHelpers';
const rendererId = uuid();
const fixtures = { first: 'First' };
const decorators = {};
const fixtureId = { path: 'first', name: null };
runFixtureLoaderTests(mount => {
it('fires change callback when selecting fixture', async () => {
const onFixtureChange = jest.fn();
await mount(
{ rendererId, fixtures, decorators, onFixtureChange },
async ({ selectFixture }) => {
await selectFixture({
rendererId,
fixtureId,
fixtureState: {}
});
await retry(() => expect(onFixtureChange).toBeCalledTimes(1));
}
);
});
it('fires change callback when unselecting fixture', async () => {
const onFixtureChange = jest.fn();
await mount(
{ rendererId, fixtures, decorators, onFixtureChange },
async ({ selectFixture, unselectFixture }) => {
await selectFixture({