How to use the cuid.default function in cuid

To help you get started, we’ve selected a few cuid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github clay / clay-kiln / test / setupFile.js View on Github external
// global functions to mount vue components
global.mount = mount;
global.shallowMount = shallowMount; // use when you don't want to render child components

// mock logger, so you can check that mockLogger was called
global.mockLogger = jest.fn();
jest.mock('clay-log', () => ({
  init: () => {},
  meta: () => mockLogger
}));

global.window.kiln = { inputs: {} };

// mock cuid because it doesn't like being run in jsdom
jest.mock('cuid');
cuid.default.mockReturnValue('abc');

// add jsdom-compliant quill polyfill for dealing with deltas
jest.mock('quill/dist/quill.min.js');
Quill.mockImplementation(function QuillMock() {
  this.root = { innerHTML: '' };
  this.setContents = function (delta) {
    this.root.innerHTML = convertDeltaToHtml(delta);
  };
  this.imports = {}; // phrase blots
  this.register = function (blotName, blotConfig) {
    this.imports[blotName] = blotConfig;
  };
});
// note: yeah, we're using actual quill deltas here. pretty snazzy eh?
Quill.import.mockImplementation(() => Delta);

cuid

Collision-resistant ids optimized for horizontal scaling and performance. For node and browsers.

MIT
Latest version published 1 year ago

Package Health Score

61 / 100
Full package analysis