mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-03-18 02:22:46 -05:00
refactor: relocate unit test
no logic change, just path updates
This commit is contained in:
parent
4e5deb4461
commit
49c6191bb5
71 changed files with 199 additions and 210 deletions
|
@ -9,13 +9,12 @@ module.exports = {
|
|||
'fixtures'
|
||||
],
|
||||
testEnvironment: 'jest-environment-jsdom-global',
|
||||
testRegex: '(/test/unit.*\\.spec|test/functional.*\\.func|/test/webui/.*\\.spec)\\.js',
|
||||
// 'testRegex': '(test/functional.*\\.func)\\.js'
|
||||
testRegex: '(/test/unit.*\\.spec|test/functional.*\\.func|/test/unit/webui/.*\\.spec)\\.js',
|
||||
setupFiles: [
|
||||
'./test/webui/global.js'
|
||||
'./test/unit/setup-webui.js'
|
||||
],
|
||||
modulePathIgnorePatterns: [
|
||||
'global.js'
|
||||
'setup-webui.js'
|
||||
],
|
||||
testPathIgnorePatterns: [
|
||||
'__snapshots__'
|
||||
|
|
|
@ -49,7 +49,7 @@ function loadPlugin(config: Config, pluginConfigs: any, params: any, sanityCheck
|
|||
let plugin;
|
||||
|
||||
// try local plugins first
|
||||
plugin = tryLoad(Path.resolve(__dirname + '/..//plugins', pluginId));
|
||||
plugin = tryLoad(Path.resolve(__dirname + '/../plugins', pluginId));
|
||||
|
||||
// npm package
|
||||
if (plugin === null && pluginId.match(/^[^\.\/]/)) {
|
||||
|
|
|
@ -4,9 +4,9 @@ const puppeteer = require('puppeteer');
|
|||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const {VerdaccioConfig} = require("../src/verdaccio-server");
|
||||
const VerdaccioProcess = require("../src/server_process");
|
||||
const Server = require("../src/server");
|
||||
const {VerdaccioConfig} = require("../lib/verdaccio-server");
|
||||
const VerdaccioProcess = require("../lib/server_process");
|
||||
const Server = require("../lib/server");
|
||||
|
||||
|
||||
const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup');
|
||||
|
|
|
@ -6,11 +6,11 @@ import path from 'path';
|
|||
import {setup} from '../../src/lib/logger';
|
||||
setup();
|
||||
|
||||
import {VerdaccioConfig} from '../src/verdaccio-server';
|
||||
import VerdaccioProcess from '../src/server_process';
|
||||
import {VerdaccioConfig} from '../lib/verdaccio-server';
|
||||
import VerdaccioProcess from '../lib/server_process';
|
||||
import ExpressServer from './lib/simple_server';
|
||||
import Server from '../src/server';
|
||||
import type {IServerProcess, IServerBridge} from '../flow/types';
|
||||
import Server from '../lib/server';
|
||||
import type {IServerProcess, IServerBridge} from '../types';
|
||||
|
||||
import basic from './basic/basic.spec';
|
||||
import packageAccess from './package/access.spec';
|
||||
|
|
|
@ -2,5 +2,5 @@ require("babel-polyfill");
|
|||
require('babel-core/register')({
|
||||
ignore: /node_modules\/(?!ProjectB)/,
|
||||
sourceMap: 'inline',
|
||||
});
|
||||
require('../../src/lib/cli');
|
||||
});
|
||||
require('../../../src/lib/cli');
|
|
@ -1,3 +1,3 @@
|
|||
#!/usr/bin/env node
|
||||
require("babel-register");
|
||||
require('../../src/lib/cli');
|
||||
require('../../../src/lib/cli');
|
|
@ -3,7 +3,7 @@
|
|||
import assert from 'assert';
|
||||
import request from 'request';
|
||||
import _ from 'lodash';
|
||||
import type {IRequestPromise} from '../flow/types';
|
||||
import type {IRequestPromise} from '../types';
|
||||
|
||||
const requestData = Symbol('smart_request_data');
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
import _ from 'lodash';
|
||||
import assert from 'assert';
|
||||
import smartRequest from './request';
|
||||
import type {IServerBridge} from '../flow/types';
|
||||
import type {IServerBridge} from '../types';
|
||||
import {HEADERS} from '../../src/lib/constants';
|
||||
|
||||
const buildAuthHeader = (user, pass): string => {
|
|
@ -3,7 +3,7 @@ import _ from 'lodash';
|
|||
import rimRaf from 'rimraf';
|
||||
import path from 'path';
|
||||
import {fork} from 'child_process';
|
||||
import type {IVerdaccioConfig, IServerBridge, IServerProcess} from '../flow/types';
|
||||
import type {IVerdaccioConfig, IServerBridge, IServerProcess} from '../types';
|
||||
|
||||
export default class VerdaccioProcess implements IServerProcess {
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// @flow
|
||||
import type {IVerdaccioConfig} from '../flow/types';
|
||||
import type {IVerdaccioConfig} from '../types';
|
||||
|
||||
export class VerdaccioConfig implements IVerdaccioConfig {
|
||||
|
|
@ -3,12 +3,12 @@ import _ from 'lodash';
|
|||
import path from 'path';
|
||||
import rimraf from 'rimraf';
|
||||
|
||||
import {HEADERS} from '../../src/lib/constants';
|
||||
import configDefault from './partials/config/access';
|
||||
import Config from '../../src/lib/config';
|
||||
import endPointAPI from '../../src/api/index';
|
||||
import {HEADERS} from '../../../src/lib/constants';
|
||||
import configDefault from '../partials/config/access';
|
||||
import Config from '../../../src/lib/config';
|
||||
import endPointAPI from '../../../src/api/index';
|
||||
|
||||
require('../../src/lib/logger').setup([]);
|
||||
require('../../../src/lib/logger').setup([]);
|
||||
|
||||
describe('api with no limited access configuration', () => {
|
||||
let config;
|
|
@ -3,14 +3,14 @@ import _ from 'lodash';
|
|||
import path from 'path';
|
||||
import rimraf from 'rimraf';
|
||||
|
||||
import configDefault from './partials/config';
|
||||
import publishMetadata from './partials/publish-api';
|
||||
import forbiddenPlace from './partials/forbidden-place';
|
||||
import Config from '../../src/lib/config';
|
||||
import endPointAPI from '../../src/api/index';
|
||||
import {HEADERS} from '../../src/lib/constants';
|
||||
import configDefault from '../partials/config/index';
|
||||
import publishMetadata from '../partials/publish-api';
|
||||
import forbiddenPlace from '../partials/forbidden-place';
|
||||
import Config from '../../../src/lib/config';
|
||||
import endPointAPI from '../../../src/api/index';
|
||||
import {HEADERS} from '../../../src/lib/constants';
|
||||
|
||||
require('../../src/lib/logger').setup([]);
|
||||
require('../../../src/lib/logger').setup([]);
|
||||
const credentials = { name: 'Jota', password: 'secretPass' };
|
||||
|
||||
describe('endpoint unit test', () => {
|
||||
|
@ -19,7 +19,7 @@ describe('endpoint unit test', () => {
|
|||
jest.setTimeout(10000);
|
||||
|
||||
beforeAll(function(done) {
|
||||
const store = path.join(__dirname, './partials/store/test-storage');
|
||||
const store = path.join(__dirname, '../partials/store/test-storage');
|
||||
rimraf(store, async () => {
|
||||
const configForTest = _.clone(configDefault);
|
||||
configForTest.auth = {
|
|
@ -1,14 +1,14 @@
|
|||
// @flow
|
||||
|
||||
import Auth from '../../src/lib/auth';
|
||||
import Auth from '../../../src/lib/auth';
|
||||
// $FlowFixMe
|
||||
import configExample from './partials/config';
|
||||
import configExample from '../partials/config/index';
|
||||
// $FlowFixMe
|
||||
import configPlugins from './partials/config/plugin';
|
||||
import AppConfig from '../../src/lib/config';
|
||||
import {setup} from '../../src/lib/logger';
|
||||
import configPlugins from '../partials/config/plugin';
|
||||
import AppConfig from '../../../src/lib/config';
|
||||
import {setup} from '../../../src/lib/logger';
|
||||
|
||||
import type {IAuth} from '../../types';
|
||||
import type {IAuth} from '../../../types/index';
|
||||
import type {Config} from '@verdaccio/types';
|
||||
|
||||
setup(configExample.logs);
|
|
@ -1,11 +1,11 @@
|
|||
import endPointAPI from '../../src/api/index';
|
||||
import endPointAPI from '../../../src/api/index';
|
||||
|
||||
const assert = require('assert');
|
||||
const express = require('express');
|
||||
const request = require('request');
|
||||
const rimraf = require('rimraf');
|
||||
|
||||
const config = require('./partials/config');
|
||||
const config = require('../partials/config/index');
|
||||
|
||||
const app = express();
|
||||
const server = require('http').createServer(app);
|
|
@ -1,10 +1,10 @@
|
|||
import startServer from '../../src';
|
||||
import {getListListenAddresses} from '../../src/lib/bootstrap';
|
||||
import config from './partials/config';
|
||||
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([]);
|
||||
require('../../../src/lib/logger').setup([]);
|
||||
|
||||
describe('startServer via API', () => {
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
const assert = require('assert');
|
||||
const Utils = require('../../src/lib/utils');
|
||||
const Config = require('../../src/lib/config');
|
||||
const Utils = require('../../../src/lib/utils');
|
||||
const Config = require('../../../src/lib/config');
|
||||
const path = require('path');
|
||||
const _ = require('lodash');
|
||||
|
||||
const resolveConf = (conf) => path.join(__dirname, `../../conf/${conf}.yaml`);
|
||||
const resolveConf = (conf) => path.join(__dirname, `../../../conf/${conf}.yaml`);
|
||||
|
||||
const checkUplink = (config) => {
|
||||
assert.equal(_.isObject(config.uplinks['npmjs']), true);
|
|
@ -1,6 +1,6 @@
|
|||
const assert = require('assert');
|
||||
const _ = require('lodash');
|
||||
const parse = require('../../src/lib/utils').parse_address;
|
||||
const parse = require('../../../src/lib/utils').parse_address;
|
||||
|
||||
describe('Parse listen address', () => {
|
||||
function addTest(what, proto, host, port) {
|
|
@ -2,17 +2,17 @@
|
|||
|
||||
import rimRaf from 'rimraf';
|
||||
import path from 'path';
|
||||
import LocalStorage from '../../src/lib/local-storage';
|
||||
import AppConfig from '../../src/lib/config';
|
||||
import LocalStorage from '../../../src/lib/local-storage';
|
||||
import AppConfig from '../../../src/lib/config';
|
||||
// $FlowFixMe
|
||||
import configExample from './partials/config';
|
||||
import Logger, {setup} from '../../src/lib/logger';
|
||||
import {readFile} from '../functional/lib/test.utils';
|
||||
import configExample from '../partials/config/index';
|
||||
import Logger, {setup} from '../../../src/lib/logger';
|
||||
import {readFile} from '../../functional/lib/test.utils';
|
||||
|
||||
const readMetadata = (fileName: string = 'metadata') => readFile(`../../unit/partials/${fileName}`);
|
||||
|
||||
import type {Config} from '@verdaccio/types';
|
||||
import type {IStorage} from '../../types';
|
||||
import type {IStorage} from '../../../types/index';
|
||||
|
||||
setup([]);
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import assert from 'assert';
|
||||
import Storage from '../../src/lib/up-storage';
|
||||
import Storage from '../../../src/lib/up-storage';
|
||||
|
||||
require('../../src/lib/logger').setup([]);
|
||||
require('../../../src/lib/logger').setup([]);
|
||||
|
||||
function setupProxy(host, config, mainconfig) {
|
||||
config.url = host;
|
|
@ -1,5 +1,5 @@
|
|||
let assert = require('assert');
|
||||
let parseInterval = require('../../src/lib/utils').parseInterval;
|
||||
let parseInterval = require('../../../src/lib/utils').parseInterval;
|
||||
|
||||
describe('Parse interval', () => {
|
||||
function add_test(str, res) {
|
79
test/unit/api/plugin_loader.spec.js
Normal file
79
test/unit/api/plugin_loader.spec.js
Normal file
|
@ -0,0 +1,79 @@
|
|||
import path from 'path';
|
||||
import {loadPlugin} from '../../../src/lib/plugin-loader';
|
||||
import logger from '../../../src/lib/logger';
|
||||
|
||||
logger.setup([]);
|
||||
|
||||
describe('plugin loader', () => {
|
||||
|
||||
const relativePath = './partials/test-plugin-storage';
|
||||
const buildConf = name => {
|
||||
return {
|
||||
self_path: path.join(__dirname, './'),
|
||||
max_users: 0,
|
||||
auth: {
|
||||
[`${relativePath}/${name}`]: {}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
describe('auth plugins', () => {
|
||||
test('testing auth valid plugin loader', () => {
|
||||
const _config = buildConf('verdaccio-plugin');
|
||||
const plugins = loadPlugin(_config, _config.auth, {}, function (plugin) {
|
||||
return plugin.authenticate || plugin.allow_access || plugin.allow_publish;
|
||||
});
|
||||
|
||||
expect(plugins).toHaveLength(1);
|
||||
});
|
||||
|
||||
test('testing storage valid plugin loader', () => {
|
||||
const _config = buildConf('verdaccio-es6-plugin');
|
||||
const plugins = loadPlugin(_config, _config.auth, {}, function (p) {
|
||||
return p.getPackageStorage;
|
||||
});
|
||||
|
||||
expect(plugins).toHaveLength(1);
|
||||
});
|
||||
|
||||
test('testing auth plugin invalid plugin', () => {
|
||||
const _config = buildConf('invalid-plugin');
|
||||
try {
|
||||
loadPlugin(_config, _config.auth, {}, function (p) {
|
||||
return p.authenticate || p.allow_access || p.allow_publish;
|
||||
});
|
||||
} catch(e) {
|
||||
expect(e.message).toEqual(`"${relativePath}/invalid-plugin" doesn\'t look like a valid plugin`);
|
||||
}
|
||||
});
|
||||
|
||||
test('testing auth plugin invalid plugin sanityCheck', () => {
|
||||
const _config = buildConf('invalid-plugin-sanity');
|
||||
try {
|
||||
loadPlugin(_config, _config.auth, {}, function (plugin) {
|
||||
return plugin.authenticate || plugin.allow_access || plugin.allow_publish;
|
||||
});
|
||||
} catch(err) {
|
||||
expect(err.message).toEqual(`"${relativePath}/invalid-plugin-sanity" doesn\'t look like a valid plugin`);
|
||||
}
|
||||
});
|
||||
|
||||
test('testing auth plugin no plugins', () => {
|
||||
const _config = buildConf('invalid-package');
|
||||
try {
|
||||
loadPlugin(_config, _config.auth, {}, function (plugin) {
|
||||
return plugin.authenticate || plugin.allow_access || plugin.allow_publish;
|
||||
});
|
||||
} catch(e) {
|
||||
expect(e.message).toMatch('plugin not found');
|
||||
expect(e.message).toMatch('/partials/test-plugin-storage/invalid-package');
|
||||
}
|
||||
});
|
||||
|
||||
// FUTURE: the following groups should be here
|
||||
// middleware plugins
|
||||
// storage plugins
|
||||
|
||||
});
|
||||
|
||||
});
|
|
@ -1,12 +1,12 @@
|
|||
|
||||
|
||||
import assert from 'assert';
|
||||
import Search from '../../src/lib/search';
|
||||
import Storage from '../../src/lib/storage';
|
||||
let config_hash = require('./partials/config');
|
||||
let Config = require('../../src/lib/config');
|
||||
import Search from '../../../src/lib/search';
|
||||
import Storage from '../../../src/lib/storage';
|
||||
let config_hash = require('../partials/config/index');
|
||||
let Config = require('../../../src/lib/config');
|
||||
|
||||
require('../../src/lib/logger').setup([]);
|
||||
require('../../../src/lib/logger').setup([]);
|
||||
|
||||
let packages = [
|
||||
{
|
|
@ -1,8 +1,8 @@
|
|||
let assert = require('assert');
|
||||
let semverSort = require('../../src/lib/utils').semverSort;
|
||||
import {mergeVersions} from '../../src/lib/metadata-utils';
|
||||
let semverSort = require('../../../src/lib/utils').semverSort;
|
||||
import {mergeVersions} from '../../../src/lib/metadata-utils';
|
||||
|
||||
require('../../src/lib/logger').setup([]);
|
||||
require('../../../src/lib/logger').setup([]);
|
||||
|
||||
describe('Storage._merge_versions versions', () => {
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
// @flow
|
||||
|
||||
import {DEFAULT_REVISION, normalizePackage, mergeUplinkTimeIntoLocal} from "../../src/lib/storage-utils";
|
||||
import {DIST_TAGS} from "../../src/lib/utils";
|
||||
import {readFile} from "../functional/lib/test.utils";
|
||||
import {DEFAULT_REVISION, normalizePackage, mergeUplinkTimeIntoLocal} from "../../../src/lib/storage-utils";
|
||||
import {DIST_TAGS} from "../../../src/lib/utils";
|
||||
import {readFile} from "../../functional/lib/test.utils";
|
||||
|
||||
import type {Package} from '@verdaccio/types';
|
||||
|
|
@ -3,13 +3,13 @@
|
|||
import _ from 'lodash';
|
||||
import httpMocks from 'node-mocks-http';
|
||||
// $FlowFixMe
|
||||
import configExample from './partials/config';
|
||||
import AppConfig from '../../src/lib/config';
|
||||
import Storage from '../../src/lib/storage';
|
||||
import {setup} from '../../src/lib/logger';
|
||||
import configExample from '../partials/config/index';
|
||||
import AppConfig from '../../../src/lib/config';
|
||||
import Storage from '../../../src/lib/storage';
|
||||
import {setup} from '../../../src/lib/logger';
|
||||
|
||||
import type {Config} from '@verdaccio/types';
|
||||
import type {IStorageHandler} from '../../types';
|
||||
import type {IStorageHandler} from '../../../types/index';
|
||||
|
||||
setup(configExample.logs);
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
let assert = require('assert');
|
||||
let tag_version = require('../../src/lib/utils').tagVersion;
|
||||
let tag_version = require('../../../src/lib/utils').tagVersion;
|
||||
|
||||
require('../../src/lib/logger').setup([]);
|
||||
require('../../../src/lib/logger').setup([]);
|
||||
|
||||
describe('tag_version', () => {
|
||||
test('add new one', () => {
|
|
@ -1,13 +1,13 @@
|
|||
// @flow
|
||||
import _ from 'lodash';
|
||||
import ProxyStorage, {DEFAULT_REGISTRY} from '../../src/lib/up-storage';
|
||||
import AppConfig from '../../src/lib/config';
|
||||
import ProxyStorage, {DEFAULT_REGISTRY} from '../../../src/lib/up-storage';
|
||||
import AppConfig from '../../../src/lib/config';
|
||||
// $FlowFixMe
|
||||
import configExample from './partials/config';
|
||||
import {setup} from '../../src/lib/logger';
|
||||
import configExample from '../partials/config/index';
|
||||
import {setup} from '../../../src/lib/logger';
|
||||
|
||||
import type {Config, UpLinkConf} from '@verdaccio/types';
|
||||
import type {IProxy} from '../../types';
|
||||
import type {IProxy} from '../../../types/index';
|
||||
|
||||
setup([]);
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
// @flow
|
||||
import assert from 'assert';
|
||||
import {validateName as validate, convertDistRemoteToLocalTarballUrls, parseReadme} from '../../src/lib/utils';
|
||||
import {generateGravatarUrl, GRAVATAR_DEFAULT} from '../../src/utils/user';
|
||||
import {spliceURL} from '../../src/utils/string';
|
||||
import Package from '../../src/webui/src/components/Package';
|
||||
import Logger, {setup} from '../../src/lib/logger';
|
||||
import { readFile } from '../functional/lib/test.utils';
|
||||
import {generateGravatarUrl, GRAVATAR_DEFAULT} from '../../../src/utils/user';
|
||||
import {spliceURL} from '../../../src/utils/string';
|
||||
import Package from "../../../src/webui/src/components/Package/index";
|
||||
import {validateName as validate, convertDistRemoteToLocalTarballUrls, parseReadme} from '../../../src/lib/utils';
|
||||
import Logger, {setup} from '../../../src/lib/logger';
|
||||
import { readFile } from '../../functional/lib/test.utils';
|
||||
|
||||
const readmeFile = (fileName: string = 'markdown.md') => readFile(`../../unit/partials/readme/${fileName}`);
|
||||
|
||||
|
@ -133,7 +133,7 @@ describe('Utilities', () => {
|
|||
const randomText = '%%%%%**##==';
|
||||
const randomTextNonAscii = 'simple text \n = ascii';
|
||||
const randomTextMarkdown = 'simple text \n # markdown';
|
||||
|
||||
|
||||
expect(parseReadme('testPackage', randomText)).toEqual('<p>%%%%%**##==</p>\n');
|
||||
expect(parseReadme('testPackage', simpleText)).toEqual('<p>simple text</p>\n');
|
||||
expect(parseReadme('testPackage', randomTextNonAscii))
|
|
@ -1,5 +1,4 @@
|
|||
// ensure that all arguments are validated
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
|
||||
/**
|
||||
|
@ -16,12 +15,11 @@ describe('api endpoint app.param()', runTest('../endpoint/index.js'));
|
|||
function runTest(file) {
|
||||
return function() {
|
||||
|
||||
let requirePath = path.normalize(path.join(__dirname + '/../../src/api/web/', file));
|
||||
let source = require('fs').readFileSync(requirePath, 'utf8');
|
||||
|
||||
let very_scary_regexp = /\n\s*app\.(\w+)\s*\(\s*(("[^"]*")|('[^']*'))\s*,/g;
|
||||
let m;
|
||||
let appParams = {};
|
||||
const requirePath = path.normalize(path.join(__dirname + '/../../../src/api/web/', file));
|
||||
const source = require('fs').readFileSync(requirePath, 'utf8');
|
||||
const very_scary_regexp = /\n\s*app\.(\w+)\s*\(\s*(("[^"]*")|('[^']*'))\s*,/g;
|
||||
const appParams = {};
|
||||
|
||||
// look up for matches in the source code
|
||||
while ((m = very_scary_regexp.exec(source)) != null) {
|
||||
|
@ -40,12 +38,11 @@ function runTest(file) {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
Object.keys(appParams).forEach(function(param) {
|
||||
test('should validate ":'+param+'"', () => {
|
||||
assert.equal(appParams[param], 'ok');
|
||||
});
|
||||
});
|
||||
Object.keys(appParams).forEach(function(param) {
|
||||
test('should validate ":'+param+'"', () => {
|
||||
expect(appParams[param]).toEqual('ok');
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
// @flow
|
||||
|
||||
import _ from 'lodash';
|
||||
import smartRequest, {PromiseAssert} from '../../src/request';
|
||||
import type {IRequestPromise} from '../../flow/types';
|
||||
import smartRequest, {PromiseAssert} from '../../lib/request';
|
||||
import type {IRequestPromise} from '../../types';
|
||||
|
||||
describe('Request Functional', () => {
|
||||
|
||||
|
|
|
@ -1,86 +0,0 @@
|
|||
|
||||
import {loadPlugin} from '../../src/lib/plugin-loader';
|
||||
import assert from 'assert';
|
||||
import path from 'path';
|
||||
|
||||
require('../../src/lib/logger').setup([]);
|
||||
|
||||
describe('plugin loader', () => {
|
||||
|
||||
test('testing auth valid plugin loader', () => {
|
||||
let _config = {
|
||||
self_path: path.join(__dirname, './'),
|
||||
max_users: 0,
|
||||
auth: {
|
||||
'./unit/partials/test-plugin-storage/verdaccio-plugin': {}
|
||||
}
|
||||
}
|
||||
let plugins = loadPlugin(_config, _config.auth, {}, function (p) {
|
||||
return p.authenticate || p.allow_access || p.allow_publish;
|
||||
});
|
||||
assert(plugins.length === 1);
|
||||
});
|
||||
|
||||
test('testing storage valid plugin loader', () => {
|
||||
let _config = {
|
||||
self_path: path.join(__dirname, './'),
|
||||
max_users: 0,
|
||||
auth: {
|
||||
'./unit/partials/test-plugin-storage/verdaccio-es6-plugin': {}
|
||||
}
|
||||
}
|
||||
let plugins = loadPlugin(_config, _config.auth, {}, function (p) {
|
||||
return p.getPackageStorage;
|
||||
});
|
||||
assert(plugins.length === 1);
|
||||
});
|
||||
|
||||
test('testing auth plugin invalid plugin', () => {
|
||||
let _config = {
|
||||
self_path: path.join(__dirname, './'),
|
||||
auth: {
|
||||
'./unit/partials/test-plugin-storage/invalid-plugin': {}
|
||||
}
|
||||
}
|
||||
try {
|
||||
loadPlugin(_config, _config.auth, {}, function (p) {
|
||||
return p.authenticate || p.allow_access || p.allow_publish;
|
||||
});
|
||||
} catch(e) {
|
||||
assert(e.message === '"./unit/partials/test-plugin-storage/invalid-plugin" doesn\'t look like a valid plugin');
|
||||
}
|
||||
});
|
||||
|
||||
test('testing auth plugin invalid plugin sanityCheck', () => {
|
||||
let _config = {
|
||||
self_path: path.join(__dirname, './'),
|
||||
auth: {
|
||||
'./unit/partials/test-plugin-storage/invalid-plugin-sanity': {}
|
||||
}
|
||||
}
|
||||
try {
|
||||
loadPlugin(_config, _config.auth, {}, function (plugin) {
|
||||
return plugin.authenticate || plugin.allow_access || plugin.allow_publish;
|
||||
});
|
||||
} catch(err) {
|
||||
assert(err.message === '"./unit/partials/test-plugin-storage/invalid-plugin-sanity" doesn\'t look like a valid plugin');
|
||||
}
|
||||
});
|
||||
|
||||
test('testing auth plugin no plugins', () => {
|
||||
let _config = {
|
||||
self_path: path.join(__dirname, './'),
|
||||
auth: {
|
||||
'./unit/partials/test-plugin-storage/invalid-package': {}
|
||||
}
|
||||
}
|
||||
try {
|
||||
loadPlugin(_config, _config.auth, {}, function (plugin) {
|
||||
return plugin.authenticate || plugin.allow_access || plugin.allow_publish;
|
||||
});
|
||||
} catch(e) {
|
||||
assert(e.message === `"./unit/partials/test-plugin-storage/invalid-package" plugin not found\ntry "npm install verdaccio-./unit/partials/test-plugin-storage/invalid-package"`);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { mount, shallow } from 'enzyme';
|
||||
import Dependencies from '../../../../src/webui/src/components/PackageSidebar/modules/Dependencies/';
|
||||
import Dependencies from '../../../../../src/webui/src/components/PackageSidebar/modules/Dependencies/index';
|
||||
import { packageMeta } from '../store/packageMeta';
|
||||
|
||||
console.error = jest.fn();
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { mount, shallow } from 'enzyme';
|
||||
import Infos from '../../../../src/webui/src/components/PackageSidebar/modules/Infos';
|
||||
import Infos from '../../../../../src/webui/src/components/PackageSidebar/modules/Infos/index';
|
||||
import { packageMeta } from '../store/packageMeta';
|
||||
|
||||
console.error = jest.fn();
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { mount, shallow } from 'enzyme';
|
||||
import LastSync from '../../../../src/webui/src/components/PackageSidebar/modules/LastSync';
|
||||
import LastSync from '../../../../../src/webui/src/components/PackageSidebar/modules/LastSync/index';
|
||||
import { packageMeta } from '../store/packageMeta';
|
||||
|
||||
console.error = jest.fn();
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import MaintainerInfo from '../../../../src/webui/src/components/PackageSidebar/modules/Maintainers/MaintainerInfo';
|
||||
import MaintainerInfo from '../../../../../src/webui/src/components/PackageSidebar/modules/Maintainers/MaintainerInfo/index';
|
||||
|
||||
console.error = jest.fn();
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import Maintainers from '../../../../src/webui/src/components/PackageSidebar/modules/Maintainers';
|
||||
import Maintainers from '../../../../../src/webui/src/components/PackageSidebar/modules/Maintainers/index';
|
||||
import { packageMeta } from '../store/packageMeta';
|
||||
|
||||
console.error = jest.fn();
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import Module from '../../../../src/webui/src/components/PackageSidebar/Module';
|
||||
import Module from '../../../../../src/webui/src/components/PackageSidebar/Module/index';
|
||||
|
||||
console.error = jest.fn();
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import ModuleContentPlaceholder from '../../../../src/webui/src/components/PackageSidebar/ModuleContentPlaceholder';
|
||||
import ModuleContentPlaceholder from '../../../../../src/webui/src/components/PackageSidebar/ModuleContentPlaceholder/index';
|
||||
|
||||
console.error = jest.fn();
|
||||
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import PackageSidebar from '../../../../src/webui/src/components/PackageSidebar';
|
||||
import PackageSidebar from '../../../../../src/webui/src/components/PackageSidebar/index';
|
||||
import { packageMeta } from '../store/packageMeta';
|
||||
|
||||
jest.mock('../../../../src/webui/utils/api', () => ({
|
||||
jest.mock('../../../../../src/webui/utils/api', () => ({
|
||||
request: require('../__mocks__/api').default.request,
|
||||
}));
|
||||
|
|
@ -3,11 +3,11 @@
|
|||
*/
|
||||
import React from 'react';
|
||||
import { shallow, mount } from 'enzyme';
|
||||
import Header from '../../../src/webui/src/components/Header';
|
||||
import Header from '../../../../src/webui/src/components/Header';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import storage from '../../../src/webui/utils/storage';
|
||||
import storage from '../../../../src/webui/utils/storage';
|
||||
|
||||
jest.mock('../../../src/webui/utils/api', () => ({
|
||||
jest.mock('../../../../src/webui/utils/api', () => ({
|
||||
request: require('./__mocks__/api').default.request,
|
||||
}));
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import SyntaxHighlighter from 'react-syntax-highlighter/dist/light';
|
||||
import Help from '../../../src/webui/src/components/Help';
|
||||
import Help from '../../../../src/webui/src/components/Help/index';
|
||||
|
||||
describe('<Help /> component', () => {
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import NoItems from '../../../src/webui/src/components/NoItems';
|
||||
import NoItems from '../../../../src/webui/src/components/NoItems/index';
|
||||
|
||||
console.error = jest.fn();
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import NotFound from '../../../src/webui/src/components/NotFound';
|
||||
import NotFound from '../../../../src/webui/src/components/NotFound/index';
|
||||
|
||||
console.error = jest.fn();
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import Package from '../../../src/webui/src/components/Package';
|
||||
import Package from '../../../../src/webui/src/components/Package/index';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
|
||||
/**
|
|
@ -3,8 +3,8 @@
|
|||
*/
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import PackageDetail from '../../../src/webui/src/components/PackageDetail';
|
||||
import Readme from '../../../src/webui/src/components/Readme';
|
||||
import PackageDetail from '../../../../src/webui/src/components/PackageDetail/index';
|
||||
import Readme from '../../../../src/webui/src/components/Readme/index';
|
||||
|
||||
console.error = jest.fn();
|
||||
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import PackageList from '../../../src/webui/src/components/PackageList';
|
||||
import Help from '../../../src/webui/src/components/Help';
|
||||
import NoItems from '../../../src/webui/src/components/NoItems';
|
||||
import PackageList from '../../../../src/webui/src/components/PackageList/index';
|
||||
import Help from '../../../../src/webui/src/components/Help/index';
|
||||
import NoItems from '../../../../src/webui/src/components/NoItems/index';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
|
||||
describe('<PackageList /> component', () => {
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import Readme from '../../../src/webui/src/components/Readme';
|
||||
import Readme from '../../../../src/webui/src/components/Readme/index';
|
||||
|
||||
console.error = jest.fn();
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import Search from '../../../src/webui/src/components/Search/index';
|
||||
import Search from '../../../../src/webui/src/components/Search/index';
|
||||
console.error = jest.fn();
|
||||
|
||||
describe('<Search /> component', () => {
|
Loading…
Add table
Reference in a new issue