0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/packages/config/test/utils.spec.ts
Juan Picado 5f3eee5eaf chore: remove a package, move constants (#2001)
* chore: remove a package, move constants

* chore: remove *
2021-04-09 17:54:26 +02:00

42 lines
1.3 KiB
TypeScript

import { spliceURL } from '../src/string';
import { createAnonymousRemoteUser, createRemoteUser, ROLES } from '../src';
describe('spliceURL', () => {
test('should splice two strings and generate a url', () => {
const url: string = spliceURL('http://domain.com', '/-/static/logo.png');
expect(url).toMatch('http://domain.com/-/static/logo.png');
});
test('should splice a empty strings and generate a url', () => {
const url: string = spliceURL('', '/-/static/logo.png');
expect(url).toMatch('/-/static/logo.png');
});
describe('createRemoteUser and createAnonymousRemoteUser', () => {
test('should create a remote user with default groups', () => {
expect(createRemoteUser('12345', ['foo', 'bar'])).toEqual({
groups: [
'foo',
'bar',
ROLES.$ALL,
ROLES.$AUTH,
ROLES.DEPRECATED_ALL,
ROLES.DEPRECATED_AUTH,
ROLES.ALL,
],
name: '12345',
real_groups: ['foo', 'bar'],
});
});
test('should create a anonymous remote user with default groups', () => {
expect(createAnonymousRemoteUser()).toEqual({
groups: [ROLES.$ALL, ROLES.$ANONYMOUS, ROLES.DEPRECATED_ALL, ROLES.DEPRECATED_ANONYMOUS],
name: undefined,
real_groups: [],
});
});
});
});