0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/test/unit/storage-utils.spec.js

47 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-06-14 15:44:06 -05:00
// @flow
import {DEFAULT_REVISION, normalizePackage} from "../../src/lib/storage-utils";
import {DIST_TAGS} from "../../src/lib/utils";
import {readFile} from "../functional/lib/test.utils";
const readMetadata = (fileName: string = 'metadata') => readFile(`../../unit/partials/${fileName}`);
describe('Storage Utils', () => {
test('normalizePackage clean', () => {
const pkg = normalizePackage({
_attachments: {},
_distfiles: {},
_rev: '',
_uplinks: {},
name: '',
versions: {},
[DIST_TAGS]: {},
});
expect(pkg).toBeDefined();
expect(pkg.time).toBeInstanceOf(Object);
expect(pkg.versions).toBeInstanceOf(Object);
expect(pkg[DIST_TAGS]).toBeInstanceOf(Object);
expect(pkg._distfiles).toBeInstanceOf(Object);
expect(pkg._attachments).toBeInstanceOf(Object);
expect(pkg._uplinks).toBeInstanceOf(Object);
});
test('normalizePackage partial metadata', () => {
const pkg = normalizePackage(readMetadata('metadata'));
expect(pkg).toBeDefined();
expect(pkg.time).toBeInstanceOf(Object);
expect(pkg.versions).toBeInstanceOf(Object);
expect(pkg[DIST_TAGS]).toBeInstanceOf(Object);
expect(pkg._distfiles).toBeInstanceOf(Object);
expect(pkg._attachments).toBeInstanceOf(Object);
expect(pkg._uplinks).toBeInstanceOf(Object);
});
test('normalizePackage partial default revision', () => {
const pkg = normalizePackage(readMetadata('metadata'));
expect(pkg).toBeDefined();
expect(pkg._rev).toBeDefined();
expect(pkg._rev).toBe(DEFAULT_REVISION);
});
});