mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-01 10:09:50 +00:00
60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
import { extractJsrPackageName } from './util.ts';
|
|
|
|
describe('modules/datasource/jsr/util', () => {
|
|
it('should extract package name', () => {
|
|
const res = extractJsrPackageName('@scope/package-name');
|
|
expect(res).toStrictEqual({
|
|
scope: 'scope',
|
|
name: 'package-name',
|
|
});
|
|
});
|
|
|
|
it('should return null for invalid name', () => {
|
|
const res = extractJsrPackageName('@invalid/package/name');
|
|
expect(res).toBeNull();
|
|
});
|
|
|
|
it('should extract a scope shorter than the JSR registration minimum', () => {
|
|
const res = extractJsrPackageName('@db/sqlite');
|
|
expect(res).toStrictEqual({
|
|
scope: 'db',
|
|
name: 'sqlite',
|
|
});
|
|
});
|
|
|
|
it('should return null for an empty scope', () => {
|
|
const res = extractJsrPackageName('@/packagename');
|
|
expect(res).toBeNull();
|
|
});
|
|
|
|
it('should return null for exceed scope max length', () => {
|
|
const res = extractJsrPackageName(`${'@a'.repeat(101)}/packagename`);
|
|
expect(res).toBeNull();
|
|
});
|
|
|
|
it('should return null for invalid scope name', () => {
|
|
const res = extractJsrPackageName('@🦕🦕🦕/package-name');
|
|
expect(res).toBeNull();
|
|
});
|
|
|
|
it('should return null for invalid package name starting with @', () => {
|
|
const res = extractJsrPackageName('@scope/@package-name');
|
|
expect(res).toBeNull();
|
|
});
|
|
|
|
it('should return null for exceed package max length', () => {
|
|
const res = extractJsrPackageName(`@scope/${'a'.repeat(59)}`);
|
|
expect(res).toBeNull();
|
|
});
|
|
|
|
it('should return null for invalid package name', () => {
|
|
const res = extractJsrPackageName('@scope/PACKAGE-NAME');
|
|
expect(res).toBeNull();
|
|
});
|
|
|
|
it('should return null for invalid package name starting with -', () => {
|
|
const res = extractJsrPackageName('@scope/-package-name');
|
|
expect(res).toBeNull();
|
|
});
|
|
});
|