1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/test/unit/api/cli.spec.js
Juan Picado @jotadeveloper 49c6191bb5
refactor: relocate unit test
no logic change, just path updates
2018-06-23 20:57:12 +02:00

65 lines
1.9 KiB
JavaScript

import startServer from '../../../src/index';
import {getListListenAddresses} from '../../../src/lib/bootstrap';
import config from '../partials/config/index';
import path from 'path';
import _ from 'lodash';
require('../../../src/lib/logger').setup([]);
describe('startServer via API', () => {
describe('startServer launcher', () => {
test('should provide all server data await/async', async (done) => {
const store = path.join(__dirname, 'partials/store');
await startServer(config, 6000, store, '1.0.0', 'verdaccio-test',
(webServer, addrs, pkgName, pkgVersion) => {
expect(webServer).toBeDefined();
expect(addrs).toBeDefined();
expect(addrs.proto).toBe('http');
expect(addrs.host).toBe('localhost');
expect(addrs.port).toBe('6000');
expect(pkgName).toBeDefined();
expect(pkgVersion).toBeDefined();
expect(pkgVersion).toBe('1.0.0');
expect(pkgName).toBe('verdaccio-test');
done();
});
});
test('should fails if config is missing', async () => {
try {
await startServer();
} catch (e) {
expect(e.message).toEqual('config file must be an object');
}
});
});
describe('getListListenAddresses test', () => {
test('should return by default 4873', () => {
const addrs = getListListenAddresses()[0];
expect(addrs.proto).toBe('http');
expect(addrs.host).toBe('localhost');
expect(addrs.port).toBe('4873');
});
test('should return a list of address and no cli argument provided', () => {
const addrs = getListListenAddresses(null, ['1000', '2000']);
expect(_.isArray(addrs)).toBeTruthy();
});
test('should return an address and no cli argument provided', () => {
const addrs = getListListenAddresses(null, '1000');
expect(_.isArray(addrs)).toBeTruthy();
});
});
});