mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
refactor: relocate unit test
This commit is contained in:
parent
a038b282ec
commit
cda92ac5ab
9 changed files with 62 additions and 34 deletions
|
@ -56,7 +56,7 @@ describe('Create registry servers', function() {
|
|||
/* test for before() */
|
||||
});
|
||||
|
||||
require('./access')();
|
||||
require('./package/access')();
|
||||
require('./basic')();
|
||||
require('./gh29')();
|
||||
require('./tags')();
|
||||
|
@ -71,10 +71,10 @@ describe('Create registry servers', function() {
|
|||
require('./package/scoped.spec')();
|
||||
require('./security')();
|
||||
require('./adduser')();
|
||||
require('./auth/logout')();
|
||||
require('./adduser/logout')();
|
||||
require('./addtag')();
|
||||
require('./plugins')();
|
||||
require('./notify')();
|
||||
require('./notifications/notify')();
|
||||
// requires packages published to server1/server2
|
||||
require('./uplink.cache')();
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const assert = require('assert');
|
||||
const _ = require('lodash');
|
||||
const notify = require('../../src/lib/notify').notify;
|
||||
const notify = require('../../../src/lib/notify').notify;
|
||||
|
||||
module.exports = function() {
|
||||
const express = process.express;
|
|
@ -44,7 +44,7 @@ module.exports = function() {
|
|||
function checkPublish(auth, pkg, ok) {
|
||||
it(`${(ok ? 'allows' : 'forbids')} publish ${auth} to ${pkg}`, function() {
|
||||
server.authstr = auth ? buildToken(auth) : undefined;
|
||||
const req = server.putPackage(pkg, require('./lib/package')(pkg));
|
||||
const req = server.putPackage(pkg, require('../lib/package')(pkg));
|
||||
if (ok) {
|
||||
return req.status(404).body_error(/this package cannot be added/);
|
||||
} else {
|
|
@ -1,13 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
let assert = require('assert');
|
||||
let express = require('express');
|
||||
let request = require('request');
|
||||
let rimraf = require('rimraf');
|
||||
let verdaccio = require('../../');
|
||||
let config = require('./partials/config');
|
||||
const assert = require('assert');
|
||||
const express = require('express');
|
||||
const request = require('request');
|
||||
const rimraf = require('rimraf');
|
||||
const verdaccio = require('../../');
|
||||
const config = require('./partials/config');
|
||||
|
||||
describe('toplevel', function() {
|
||||
describe('basic system test', function() {
|
||||
let port;
|
||||
|
||||
before(function(done) {
|
||||
|
@ -18,14 +18,14 @@ describe('toplevel', function() {
|
|||
let app = express();
|
||||
app.use(verdaccio(config));
|
||||
|
||||
let server = require('http').createServer(app);
|
||||
const server = require('http').createServer(app);
|
||||
server.listen(0, function() {
|
||||
port = server.address().port;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should respond on /', function(done) {
|
||||
it('server should respond on /', function(done) {
|
||||
request({
|
||||
url: 'http://localhost:' + port + '/',
|
||||
}, function(err, res, body) {
|
||||
|
@ -35,7 +35,7 @@ describe('toplevel', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should respond on /whatever', function(done) {
|
||||
it('server should respond on /whatever', function(done) {
|
||||
request({
|
||||
url: 'http://localhost:' + port + '/whatever',
|
||||
}, function(err, res, body) {
|
|
@ -1,17 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const config_hash = require('./partials/config');
|
||||
const Config = require('../../src/lib/config');
|
||||
|
||||
|
||||
describe('Config', function() {
|
||||
before(function() {
|
||||
this.config = new Config(config_hash);
|
||||
});
|
||||
|
||||
it('npmjs uplink should have a default cache option that is true', function() {
|
||||
assert.equal(this.config.uplinks['npmjs'].cache, true);
|
||||
});
|
||||
});
|
||||
|
45
test/unit/config.spec.js
Normal file
45
test/unit/config.spec.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const Utils = require('../../src/lib/utils');
|
||||
const Config = require('../../src/lib/config');
|
||||
const path = require('path');
|
||||
const _ = require('lodash');
|
||||
|
||||
const resolveConf = (conf) => {
|
||||
const fullConfigPath = path.join(__dirname, `../../conf/${conf}.yaml`);
|
||||
return fullConfigPath;
|
||||
};
|
||||
|
||||
const validateConfigFile = (config) => {
|
||||
assert.ok(_.isObject(config.uplinks['npmjs']));
|
||||
}
|
||||
|
||||
describe('Config file', function() {
|
||||
before(function() {
|
||||
|
||||
this.config = new Config(Utils.parseConfigFile(resolveConf('full')));
|
||||
});
|
||||
|
||||
describe('Config file', function() {
|
||||
it('parse full.yaml', function () {
|
||||
const config = new Config(Utils.parseConfigFile(resolveConf('full')));
|
||||
validateConfigFile(config);
|
||||
});
|
||||
|
||||
it('parse docker.yaml', function () {
|
||||
const config = new Config(Utils.parseConfigFile(resolveConf('docker')));
|
||||
validateConfigFile(config);
|
||||
});
|
||||
|
||||
it('parse default.yaml', function () {
|
||||
const config = new Config(Utils.parseConfigFile(resolveConf('default')));
|
||||
validateConfigFile(config);
|
||||
});
|
||||
});
|
||||
|
||||
it('npmjs uplink should have a default cache option that is true', () => {
|
||||
assert.equal(this.config.uplinks['npmjs'].cache, true);
|
||||
});
|
||||
});
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
let assert = require('assert');
|
||||
let parse = require('../../src/lib/utils').parse_address;
|
||||
const assert = require('assert');
|
||||
const parse = require('../../src/lib/utils').parse_address;
|
||||
|
||||
describe('Parse address', function() {
|
||||
function addTest(what, proto, host, port) {
|
||||
|
|
Loading…
Reference in a new issue