0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/packages/config/test/builder.spec.ts

66 lines
1.9 KiB
TypeScript
Raw Normal View History

import { ConfigBuilder } from '../src';
describe('Config builder', () => {
test('should create a configuration file as object', () => {
const config = ConfigBuilder.build();
config
.addUplink('upstream', { url: 'https://registry.verdaccio.org' })
.addUplink('upstream2', { url: 'https://registry.verdaccio.org' })
.addPackageAccess('upstream/*', {
access: 'public',
publish: 'foo, bar',
unpublish: 'foo, bar',
proxy: 'some',
})
.addLogger({ level: 'info', type: 'stdout', format: 'json' })
.addStorage('/tmp/verdaccio')
.addSecurity({ api: { legacy: true } });
expect(config.getConfig()).toEqual({
security: {
api: {
legacy: true,
},
},
storage: '/tmp/verdaccio',
packages: {
'upstream/*': {
access: 'public',
publish: 'foo, bar',
unpublish: 'foo, bar',
proxy: 'some',
},
},
uplinks: {
upstream: {
url: 'https://registry.verdaccio.org',
},
upstream2: {
url: 'https://registry.verdaccio.org',
},
},
log: {
level: 'info',
type: 'stdout',
format: 'json',
},
});
});
test('should create a configuration file as yaml', () => {
const config = ConfigBuilder.build();
config
.addUplink('upstream', { url: 'https://registry.verdaccio.org' })
.addUplink('upstream2', { url: 'https://registry.verdaccio.org' })
.addPackageAccess('upstream/*', {
access: 'public',
publish: 'foo, bar',
unpublish: 'foo, bar',
proxy: 'some',
})
.addLogger({ level: 'info', type: 'stdout', format: 'json' })
.addStorage('/tmp/verdaccio')
.addSecurity({ api: { legacy: true } });
expect(config.getAsYaml()).toMatchSnapshot();
});
});