1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/test/unit/api/config.spec.js

58 lines
2.0 KiB
JavaScript
Raw Normal View History

2017-08-02 20:45:21 +02:00
const assert = require('assert');
const Utils = require('../../../src/lib/utils');
const Config = require('../../../src/lib/config');
2017-08-02 20:45:21 +02:00
const path = require('path');
const _ = require('lodash');
const resolveConf = (conf) => path.join(__dirname, `../../../conf/${conf}.yaml`);
const checkUplink = (config) => {
assert.equal(_.isObject(config.uplinks['npmjs']), true);
assert.equal(config.uplinks['npmjs'].url, 'https://registry.npmjs.org');
2017-08-02 20:45:21 +02:00
};
const checkPackages = (config) => {
assert.equal(_.isObject(config.packages), true);
assert.equal(Object.keys(config.packages).join('|'), '@*/*|**');
assert.equal(config.packages['@*/*'].access, '$all');
assert.equal(config.packages['@*/*'].publish, '$authenticated');
assert.equal(config.packages['@*/*'].proxy, 'npmjs');
assert.equal(config.packages['**'].access, '$all');
assert.equal(config.packages['**'].publish, '$authenticated');
assert.equal(config.packages['**'].proxy, 'npmjs');
assert.equal(config.uplinks['npmjs'].url, 'https://registry.npmjs.org');
};
2017-08-02 20:45:21 +02:00
2017-11-01 17:47:20 +01:00
describe('Config file', () => {
beforeAll(function() {
2017-08-02 20:45:21 +02:00
this.config = new Config(Utils.parseConfigFile(resolveConf('full')));
});
describe('Config file', () => {
2017-11-01 17:47:20 +01:00
test('parse full.yaml', () => {
2017-08-02 20:45:21 +02:00
const config = new Config(Utils.parseConfigFile(resolveConf('full')));
checkUplink(config);
assert.equal(config.storage, './storage');
assert.equal(config.web.title, 'Verdaccio');
checkPackages(config);
2017-08-02 20:45:21 +02:00
});
2017-11-01 17:47:20 +01:00
test('parse docker.yaml', () => {
2017-08-02 20:45:21 +02:00
const config = new Config(Utils.parseConfigFile(resolveConf('docker')));
checkUplink(config);
assert.equal(config.storage, '/verdaccio/storage');
assert.equal(config.auth.htpasswd.file, '/verdaccio/conf/htpasswd');
2017-08-02 20:45:21 +02:00
});
2017-11-01 17:47:20 +01:00
test('parse default.yaml', () => {
2017-08-02 20:45:21 +02:00
const config = new Config(Utils.parseConfigFile(resolveConf('default')));
checkUplink(config);
assert.equal(config.storage, './storage');
assert.equal(config.auth.htpasswd.file, './htpasswd');
2017-08-02 20:45:21 +02:00
});
});
});