0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-27 22:59:51 -05:00
verdaccio/packages/tools/helpers/tests/getDeprecatedPackageMetadata.spec.ts
Juan Picado 5cbee6f57f
fix: unpublish a package on storage package (#4937)
* fix: unpublish a package on storage package

fix: unpublish a package on storage package

fix unpublish e2e

* Update index.ts

* reuse cli e2e tests

* npm 10 migrated

* migrate tests

* migrate tests

* clean up

* Create hot-crews-live.md
2024-11-16 20:39:47 +01:00

40 lines
1.4 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { Manifest } from '@verdaccio/types';
import { getDeprecatedPackageMetadata } from '../src/getDeprecatedPackageMetadata';
import { DistTags } from '../src/types';
describe('getDeprecatedPackageMetadata', () => {
const pkgName = 'test-package';
const version = '2.0.0';
const distTags: DistTags = { latest: '2.0.0' };
const deprecatedMessage = 'This package version is deprecated';
const rev = 'rev-bar';
it('should generate a deprecated package manifest with default values', () => {
const result: Manifest = getDeprecatedPackageMetadata(pkgName);
expect(result.name).toBe(pkgName);
expect(result.versions['1.0.0'].deprecated).toBe('default deprecated message');
expect(result._rev).toBe('rev-foo');
expect(result._attachments).toEqual({});
});
it('should generate a deprecated package manifest with specified version, distTags, and deprecated message', () => {
const result: Manifest = getDeprecatedPackageMetadata(
pkgName,
version,
distTags,
deprecatedMessage,
rev
);
expect(result.name).toBe(pkgName);
expect(result.versions[version]).toBeDefined();
expect(result.versions[version].deprecated).toBe(deprecatedMessage);
expect(result['dist-tags']).toEqual(distTags);
expect(result._rev).toBe(rev);
expect(result._attachments).toEqual({});
});
});