From ca5fd82d95a34b84d0336eb6ef54a60baec5e642 Mon Sep 17 00:00:00 2001 From: "Juan Picado @jotadeveloper" Date: Sat, 2 Dec 2017 11:19:08 +0100 Subject: [PATCH] refactor: jest migration completed --- jest.config.js | 1 + package.json | 2 +- test/functional/adduser/adduser.js | 29 +++--- test/functional/adduser/logout.js | 11 +-- .../{basic.js => basic/basic.spec.js} | 97 +++++++++---------- test/functional/basic/ping.js | 2 +- test/functional/basic/whoIam.js | 2 +- test/functional/gh29.js | 37 +++---- test/functional/index.func.js | 71 ++++++++++---- test/functional/lib/server_process.js | 5 +- test/functional/notifications/notify.js | 55 ++++++----- test/functional/performance/race.js | 23 ++--- test/functional/plugins/auth.spec.js | 50 +++++----- test/functional/plugins/middleware.spec.js | 4 +- test/functional/readme/readme.spec.js | 21 ++-- test/functional/sanity/incomplete.js | 17 ++-- test/functional/sanity/mirror.js | 36 +++---- test/functional/sanity/nullstorage.js | 41 ++++---- test/functional/sanity/racycrash.js | 16 ++- test/functional/sanity/security.js | 29 +++--- test/functional/tags/addtag.spec.js | 25 +++-- test/functional/tags/preserve_tags.spec.js | 36 +++---- .../functional/tags/{tags.js => tags.spec.js} | 42 ++++---- test/functional/uplink.auth.spec.js | 62 ++++++------ test/functional/uplink.cache.spec.js | 49 ++++------ 25 files changed, 362 insertions(+), 401 deletions(-) rename test/functional/{basic.js => basic/basic.spec.js} (60%) rename test/functional/tags/{tags.js => tags.spec.js} (82%) diff --git a/jest.config.js b/jest.config.js index 5c955d436..051bff869 100644 --- a/jest.config.js +++ b/jest.config.js @@ -9,4 +9,5 @@ module.exports = { 'fixtures' ], 'testRegex': '(/test/unit.*\\.spec|test/functional.*\\.func)\\.js' + // 'testRegex': '(test/functional.*\\.func)\\.js' }; diff --git a/package.json b/package.json index e3149ac50..85de404be 100644 --- a/package.json +++ b/package.json @@ -138,7 +138,7 @@ "prepublish": "in-publish && npm run build:webui || not-in-publish", "flow": "flow", "pretest": "npm run code:build", - "test": "cross-env jest -i", + "test": "cross-env jest", "pre:ci": "npm run build:webui", "test:only": "mocha ./test/functional ./test/unit", "coverage:publish": "codecov", diff --git a/test/functional/adduser/adduser.js b/test/functional/adduser/adduser.js index 639c3a3a5..eed0d7e33 100644 --- a/test/functional/adduser/adduser.js +++ b/test/functional/adduser/adduser.js @@ -1,51 +1,46 @@ -'use strict'; +import fs from 'fs'; +import path from 'path'; -import Server from '../lib/server'; -const fs = require('fs'); -const path = require('path'); - -module.exports = function() { - const server = new Server('http://localhost:55551/'); - - describe('npm adduser', function() { +export default function(server) { + describe('npm adduser', () => { const user = String(Math.random()); const pass = String(Math.random()); - before(function() { + beforeAll(function() { return server.auth(user, pass) .status(201) .body_ok(/user .* created/); }); - it('should create new user', function() {}); + test('should create new user', () => {}); - it('should log in', function() { + test('should log in', () => { return server.auth(user, pass) .status(201) .body_ok(/you are authenticated as/); }); - it('should not register more users', function() { + test('should not register more users', () => { return server.auth(String(Math.random()), String(Math.random())) .status(409) .body_error(/maximum amount of users reached/); }); }); - describe('should adduser created with htpasswd', function() { + describe('should adduser created with htpasswd', () => { const user = 'preexisting'; const pass = 'preexisting'; - before(function() { + beforeAll(function() { return fs.appendFileSync( path.join(__dirname, '../store/test-storage', '.htpasswd'), 'preexisting:$apr1$4YSboUa9$yVKjE7.PxIOuK3M4D7VjX.' ); }); - it('should log in', function() { + test('should log in', () => { return server.auth(user, pass) .status(201) .body_ok(/you are authenticated as/); }); }); -}; +} diff --git a/test/functional/adduser/logout.js b/test/functional/adduser/logout.js index 8bc5858f4..0e03efd91 100644 --- a/test/functional/adduser/logout.js +++ b/test/functional/adduser/logout.js @@ -1,13 +1,10 @@ -'use strict'; +export default function(server) { -module.exports = function() { - let server = process.server; - - describe('logout', function() { - it('should log out', function() { + describe('logout', () => { + test('should log out', () => { return server.logout('some-token') .status(200) .body_ok(/Logged out/); }); }); -}; +} diff --git a/test/functional/basic.js b/test/functional/basic/basic.spec.js similarity index 60% rename from test/functional/basic.js rename to test/functional/basic/basic.spec.js index 656ad86d6..62409b001 100644 --- a/test/functional/basic.js +++ b/test/functional/basic/basic.spec.js @@ -1,102 +1,96 @@ -'use strict'; - -const assert = require('assert'); -const crypto = require('crypto'); - +import assert from 'assert'; +import crypto from 'crypto'; function readfile(folderPath) { return require('fs').readFileSync(__dirname + '/' + folderPath); } function getPackage(name) { - return require('./fixtures/package')(name); + return require('../fixtures/package')(name); } function createHash() { return crypto.createHash('sha1'); } -module.exports = function () { - let server = process.server; - let server2 = process.server2; +export default function(server, server2) { + describe('basic test endpoints', () => { - describe('basic test endpoints', function () { + require('./whoIam')(server); + require('./ping')(server); - require('./basic/whoIam')(server); - require('./basic/ping')(server); + describe('handling packages', () => { - describe('handling packages', function () { - - before(function () { + beforeAll(function () { return server.addPackage('testpkg'); }); - before(function () { + beforeAll(function () { return server.addPackage('testpkg-single-tarball'); }); - it('creating new package', function () {/* test for before() */ + test('creating new package', () => {/* test for before() */ }); - it('downloading non-existent tarball', function () { + test('downloading non-existent tarball', () => { return server.getTarball('testpkg', 'blahblah').status(404).body_error(/no such file/); }); - it('uploading incomplete tarball', function () { - return server.putTarballIncomplete('testpkg', 'blahblah1', readfile('fixtures/binary'), 3000); + test('uploading incomplete tarball', () => { + return server.putTarballIncomplete('testpkg', 'blahblah1', readfile('../fixtures/binary'), 3000); }); - describe('publishing package', function () { + describe('publishing package', () => { - before(function () { - return server.putTarball('testpkg', 'blahblah', readfile('fixtures/binary')) + beforeAll(function () { + return server.putTarball('testpkg', 'blahblah', readfile('../fixtures/binary')) .status(201) .body_ok(/.*/); }); - before(function () { - return server.putTarball('testpkg-single-tarball', 'single', readfile('fixtures/binary')) + beforeAll(function () { + return server.putTarball('testpkg-single-tarball', 'single', readfile('../fixtures/binary')) .status(201) .body_ok(/.*/); }); - after(function () { + afterAll(function () { return server.removeTarball('testpkg').status(201); }); - it('remove a tarball', function () { + test('remove a tarball', () => { /* test for before() */ }); - it('uploading new tarball', function () { + test('uploading new tarball', () => { /* test for after() */ }); - it('remove non existing tarball', function () { + test('remove non existing tarball', () => { return server.removeTarball('testpkg404').status(404); }); - it('remove non existing single tarball', function () { + test('remove non existing single tarball', () => { return server.removeSingleTarball('', 'fakeFile').status(404); }); // testexp-incomplete - it('remove existing single tarball', function () { + test('remove existing single tarball', () => { return server.removeSingleTarball('testpkg-single-tarball', 'single').status(201); }); // testexp-incomplete - it('downloading newly created tarball', function () { + test('downloading newly created tarball', () => { return server.getTarball('testpkg', 'blahblah') .status(200) .then(function (body) { - assert.deepEqual(body, readfile('fixtures/binary')); + assert.deepEqual(body, readfile('../fixtures/binary')); }); }); - it('uploading new package version (bad sha)', function () { + test('uploading new package version (bad sha)', () => { let pkg = getPackage('testpkg'); pkg.dist.shasum = createHash().update('fake').digest('hex'); @@ -105,22 +99,22 @@ module.exports = function () { .body_error(/shasum error/); }); - describe('publishing version', function () { + describe('publishing version', () => { - before(function () { + beforeAll(function () { const pkg = getPackage('testpkg'); - pkg.dist.shasum = createHash().update(readfile('fixtures/binary')).digest('hex'); + pkg.dist.shasum = createHash().update(readfile('../fixtures/binary')).digest('hex'); return server.putVersion('testpkg', '0.0.1', pkg) .status(201) .body_ok(/published/); }); - it('uploading new package version', function () { + test('uploading new package version', () => { /* test for before() */ }); - it('downloading newly created package', function () { + test('downloading newly created package', () => { return server.getPackage('testpkg') .status(200) .then(function (body) { @@ -133,7 +127,7 @@ module.exports = function () { }); }); - it('downloading package via server2', function () { + test('downloading package via server2', () => { return server2.getPackage('testpkg') .status(200) .then(function (body) { @@ -149,26 +143,29 @@ module.exports = function () { }); }); - describe('handle failures on endpoints', function () { + describe('handle failures on endpoints', () => { - it('should fails trying to fetch non-existent package', function () { + test('should fails trying to fetch non-existent package', () => { return server.getPackage('testpkg').status(404).body_error(/no such package/); }); - it('should fails on publish a version for non existing package', function () { - return server.putVersion('testpxg', '0.0.1', getPackage('testpxg')) - .status(404) - .body_error(/no such package/); - }); + test( + 'should fails on publish a version for non existing package', + () => { + return server.putVersion('testpxg', '0.0.1', getPackage('testpxg')) + .status(404) + .body_error(/no such package/); + } + ); - it('should be a package not found', function () { - return server.putTarball('nonExistingPackage', 'blahblah', readfile('fixtures/binary')) + test('should be a package not found', () => { + return server.putTarball('nonExistingPackage', 'blahblah', readfile('../fixtures/binary')) .status(404) .body_error(/no such/); }); - it('should fails on publish package in a bad uplink', function () { + test('should fails on publish package in a bad uplink', () => { return server.putPackage('baduplink', getPackage('baduplink')) .status(503) .body_error(/one of the uplinks is down, refuse to publish/); diff --git a/test/functional/basic/ping.js b/test/functional/basic/ping.js index 581ec1029..20a5fc6b2 100644 --- a/test/functional/basic/ping.js +++ b/test/functional/basic/ping.js @@ -5,7 +5,7 @@ const _ = require('lodash'); module.exports = function(server) { - it('ping', function () { + test('ping', () => { return server.ping().then(function (data) { // it's always an empty object assert.ok(_.isObject(data)); diff --git a/test/functional/basic/whoIam.js b/test/functional/basic/whoIam.js index d2e670db5..03038c6bd 100644 --- a/test/functional/basic/whoIam.js +++ b/test/functional/basic/whoIam.js @@ -4,7 +4,7 @@ const assert = require('assert'); module.exports = function(server) { - it('who am I?', function () { + test('who am I?', () => { return server.whoami().then(function (username) { assert.equal(username, 'test'); }); diff --git a/test/functional/gh29.js b/test/functional/gh29.js index d4957bd01..8c6d07aa3 100644 --- a/test/functional/gh29.js +++ b/test/functional/gh29.js @@ -1,48 +1,44 @@ -'use strict'; - -const assert = require('assert'); -const crypto = require('crypto'); +import assert from 'assert'; +import crypto from 'crypto'; function readfile(x) { return require('fs').readFileSync(__dirname + '/' + x); } -module.exports = function() { - const server = process.server; - const server2 = process.server2; +export default function (server, server2) { - it('downloading non-existent tarball #1 / srv2', function() { + test('downloading non-existent tarball #1 / srv2', () => { return server2.getTarball('testpkg-gh29', 'blahblah') .status(404) .body_error(/no such package/); }); - describe('pkg-gh29', function() { - before(function() { + describe('pkg-gh29', () => { + beforeAll(function() { return server.putPackage('testpkg-gh29', require('./fixtures/package')('testpkg-gh29')) .status(201) .body_ok(/created new package/); }); - it('creating new package / srv1', function() {}); + test('creating new package / srv1', () => {}); - it('downloading non-existent tarball #2 / srv2', function() { + test('downloading non-existent tarball #2 / srv2', () => { return server2.getTarball('testpkg-gh29', 'blahblah') .status(404) .body_error(/no such file/); }); - describe('tarball', function() { - before(function() { + describe('tarball', () => { + beforeAll(function() { return server.putTarball('testpkg-gh29', 'blahblah', readfile('fixtures/binary')) .status(201) .body_ok(/.*/); }); - it('uploading new tarball / srv1', function() {}); + test('uploading new tarball / srv1', () => {}); - describe('pkg version', function() { - before(function() { + describe('pkg version', () => { + beforeAll(function() { const pkg = require('./fixtures/package')('testpkg-gh29'); pkg.dist.shasum = crypto.createHash('sha1').update(readfile('fixtures/binary')).digest('hex'); @@ -51,9 +47,9 @@ module.exports = function() { .body_ok(/published/); }); - it('uploading new package version / srv1', function() {}); + test('uploading new package version / srv1', () => {}); - it('downloading newly created tarball / srv2', function() { + test('downloading newly created tarball / srv2', () => { return server2.getTarball('testpkg-gh29', 'blahblah') .status(200) .then(function(body) { @@ -63,5 +59,4 @@ module.exports = function() { }); }); }); -}; - +} diff --git a/test/functional/index.func.js b/test/functional/index.func.js index df40f4b80..04212210a 100644 --- a/test/functional/index.func.js +++ b/test/functional/index.func.js @@ -1,18 +1,41 @@ // @flow import _ from 'lodash'; +// we need this for notifications +import {setup} from '../../src/lib/logger'; +setup(); + import {VerdaccioConfig} from './lib/verdaccio-server'; import VerdaccioProcess from './lib/server_process'; import ExpressServer from './lib/simple_server'; import Server from './lib/server'; import type {IServerProcess, IServerBridge} from './lib/types'; +import basic from './basic/basic.spec'; import packageAccess from './package/access.spec'; import packageGzip from './package/gzip.spec'; import packageScoped from './package/scoped.spec'; +import tags from './tags/tags.spec'; +import preserveTags from './tags/preserve_tags.spec'; +import addtag from './tags/addtag.spec'; +import adduser from './adduser/adduser'; +import logout from './adduser/logout'; +import notify from './notifications/notify'; +import incomplete from './sanity/incomplete'; +import mirror from './sanity/mirror'; +import readme from './readme/readme.spec'; +import gh29 from './gh29'; +import nullstorage from './sanity/nullstorage'; +import racycrash from './sanity/racycrash'; +import security from './sanity/security'; +import race from './performance/race'; +import pluginsAuth from './plugins/auth.spec'; +import upLinkCache from './uplink.cache.spec'; +import upLinkAuth from './uplink.auth.spec'; describe('functional test verdaccio', function() { const EXPRESS_PORT = 55550; + const SILENCE_LOG = !process.env.VERDACCIO_DEBUG; const processRunning = []; const config1 = new VerdaccioConfig( './store/test-storage', @@ -29,9 +52,9 @@ describe('functional test verdaccio', function() { const server1: IServerBridge = new Server(config1.domainPath); const server2: IServerBridge = new Server(config2.domainPath); const server3: IServerBridge = new Server(config3.domainPath); - const process1: IServerProcess = new VerdaccioProcess(config1, server1); - const process2: IServerProcess = new VerdaccioProcess(config2, server2); - const process3: IServerProcess = new VerdaccioProcess(config3, server3); + const process1: IServerProcess = new VerdaccioProcess(config1, server1, SILENCE_LOG); + const process2: IServerProcess = new VerdaccioProcess(config2, server2, SILENCE_LOG); + const process3: IServerProcess = new VerdaccioProcess(config3, server3, SILENCE_LOG); const express: any = new ExpressServer(); beforeAll((done) => { @@ -59,25 +82,35 @@ describe('functional test verdaccio', function() { express.server.close(); }); + // list of test + // note: order of the following calls is important packageAccess(server1); + basic(server1, server2); + gh29(server1, server2); + tags(server1, express.app); packageGzip(server1, express.app); + incomplete(server1, express.app); + mirror(server1, server2); + preserveTags(server1, server2, express.app); + readme(server1, server2); + nullstorage(server1, server2); + race(server1); + racycrash(server1, express.app); packageScoped(server1, server2); + security(server1); + addtag(server1); + pluginsAuth(server2); + notify(express.app); + // requires packages published to server1/server2 + upLinkCache(server1, server2, server3); + upLinkAuth(); + adduser(server1); + logout(server1); +}); - test('process test', () => { - expect(true).toBeTruthy(); - - }); - }); - - describe('package access control22', () => { - test('process test2', () => { - expect(true).toBeTruthy(); - }); - - process.on('unhandledRejection', function(err) { - console.error("unhandledRejection", err); - process.nextTick(function() { - throw err; - }); +process.on('unhandledRejection', function(err) { + console.error("unhandledRejection", err); + process.nextTick(function() { + throw err; }); }); diff --git a/test/functional/lib/server_process.js b/test/functional/lib/server_process.js index 0302e80d6..6897f61cf 100644 --- a/test/functional/lib/server_process.js +++ b/test/functional/lib/server_process.js @@ -11,9 +11,10 @@ export default class VerdaccioProcess implements IServerProcess { config: IVerdaccioConfig; childFork: any; - constructor(config: IVerdaccioConfig, bridge: IServerBridge) { + constructor(config: IVerdaccioConfig, bridge: IServerBridge, silence = true) { this.config = config; this.bridge = bridge; + this.silence = silence; } init(): Promise { @@ -30,7 +31,7 @@ export default class VerdaccioProcess implements IServerProcess { this.childFork = fork(verdaccioRegisterWrap, ['-c', configPath], { - silent: false + silent: this.silence } ); diff --git a/test/functional/notifications/notify.js b/test/functional/notifications/notify.js index cbcfbe3c6..8008177c3 100644 --- a/test/functional/notifications/notify.js +++ b/test/functional/notifications/notify.js @@ -1,12 +1,9 @@ -'use strict'; +import assert from 'assert'; +import _ from 'lodash'; -const assert = require('assert'); -const _ = require('lodash'); -const notify = require('../../../src/lib/notify').notify; - -module.exports = function() { - const express = process.express; +import {notify} from '../../../src/lib/notify'; +export default function(express) { const config = { notify: { method: 'POST', @@ -18,9 +15,9 @@ module.exports = function() { } }; - describe('notifications', function () { + describe('notifications', () => { - before(function () { + beforeAll(function () { express.post('/api/notify', function (req, res) { res.send(req.body); }); @@ -30,7 +27,7 @@ module.exports = function() { }); }); - it('notification should be send', function (done) { + test('notification should be send', done => { const metadata = { name: "pkg-test" }; @@ -46,7 +43,7 @@ module.exports = function() { }); }); - it('notification should be send single header', function (done) { + test('notification should be send single header', done => { const metadata = { name: "pkg-test" }; @@ -67,23 +64,25 @@ module.exports = function() { }); }); - it('notification should be send multiple notifications endpoints', function (done) { - const metadata = { - name: "pkg-test" - }; - // let notificationsCounter = 0; + test( + 'notification should be send multiple notifications endpoints', + done => { + const metadata = { + name: "pkg-test" + }; + // let notificationsCounter = 0; - const multipleNotificationsEndpoint = { - notify: [] - }; + const multipleNotificationsEndpoint = { + notify: [] + }; - for (let i = 0; i < 10; i++) { - const notificationSettings = _.cloneDeep(config.notify); - // basically we allow al notifications - notificationSettings.packagePattern = /^pkg-test$/; - // notificationSettings.packagePatternFlags = 'i'; - multipleNotificationsEndpoint.notify.push(notificationSettings); - } + for (let i = 0; i < 10; i++) { + const notificationSettings = _.cloneDeep(config.notify); + // basically we allow al notifications + notificationSettings.packagePattern = /^pkg-test$/; + // notificationSettings.packagePatternFlags = 'i'; + multipleNotificationsEndpoint.notify.push(notificationSettings); + } notify(metadata, multipleNotificationsEndpoint).then(function (body) { body.forEach(function(notification) { @@ -98,7 +97,7 @@ module.exports = function() { }); }); - it('notification should fails', function (done) { + test('notification should fails', done => { const metadata = { name: "pkg-test" }; @@ -115,4 +114,4 @@ module.exports = function() { }); }); -}; +} diff --git a/test/functional/performance/race.js b/test/functional/performance/race.js index 738b7bbd4..a10b463c5 100644 --- a/test/functional/performance/race.js +++ b/test/functional/performance/race.js @@ -1,23 +1,21 @@ -'use strict'; +import assert from 'assert'; +import async from 'async'; -let assert = require('assert'); -let async = require('async'); let _oksum = 0; const racePkg = require('../fixtures/package'); -module.exports = function () { - let server = process.server; +export default function(server) { - describe('race', function () { - before(function () { + describe('race', () => { + beforeAll(function () { return server.putPackage('race', racePkg('race')) .status(201) .body_ok(/created new package/); }); - it('creating new package', function () {}); + test('creating new package', () => {}); - it('uploading 10 same versions', function (callback) { + test('uploading 10 same versions', callback => { let fns = []; for (let i = 0; i < 10; i++) { fns.push(function (cb_) { @@ -64,7 +62,7 @@ module.exports = function () { }); }); - it('uploading 10 diff versions', function (callback) { + test('uploading 10 diff versions', callback => { let fns = []; for (let i = 0; i < 10; i++) { (function (i) { @@ -107,7 +105,7 @@ module.exports = function () { }); }); - after('downloading package', function () { + afterAll(function () { return server.getPackage('race') .status(200) .then(function (body) { @@ -115,5 +113,4 @@ module.exports = function () { }); }); }); -}; - +} diff --git a/test/functional/plugins/auth.spec.js b/test/functional/plugins/auth.spec.js index 600455a48..f71208005 100644 --- a/test/functional/plugins/auth.spec.js +++ b/test/functional/plugins/auth.spec.js @@ -1,11 +1,6 @@ -'use strict'; +import assert from 'assert'; -require('../lib/startup'); - -let assert = require('assert'); - -module.exports = function() { - const server2 = process.server2; +export default function(server2){ const requestAuthFail = (user, pass, message) => { return server2.auth(user, pass) .status(409) @@ -30,92 +25,91 @@ module.exports = function() { }; - describe('test default authentication', function() { + describe('test default authentication', () => { let authstr; - before(function() { + beforeAll(function() { authstr = server2.authstr; }); - it('should not authenticate with wrong password', function() { + test('should not authenticate with wrong password', () => { return requestAuthFail('authtest', 'wrongpass', 'this user already exists'); }); - it('should be wrong password handled by plugin', function() { + test('should be wrong password handled by plugin', () => { return requestAuthFail('authtest2', 'wrongpass', 'registration is disabled'); }); - it('should right password handled by plugin', function() { + test('should right password handled by plugin', () => { return requestAuthOk('authtest2', 'blahblah', /'authtest2'/); }); - after(function() { + afterAll(function() { server2.authstr = authstr; }); }); - describe('test access authorization', function() { + describe('test access authorization', () => { let authstr; - before(function() { + beforeAll(function() { authstr = server2.authstr; }); - describe('access with user authtest', function() { - before(function() { + describe('access with user authtest', () => { + beforeAll(function() { return server2.auth('authtest', 'test') .status(201) .body_ok(/'authtest'/); }); - it('access test-auth-allow', function() { + test('access test-auth-allow', () => { return server2.getPackage('test-auth-allow') .status(404) .body_error('no such package available'); }); - it('access test-auth-deny', function() { + test('access test-auth-deny', () => { return server2.getPackage('test-auth-deny') .status(403) .body_error('you\'re not allowed here'); }); - it('access test-auth-regular', function() { + test('access test-auth-regular', () => { return server2.getPackage('test-auth-regular') .status(404) .body_error('no such package available'); }); }); - describe('access with user authtest2', function() { - before(function() { + describe('access with user authtest2', () => { + beforeAll(function() { return server2.auth('authtest2', 'blahblah') .status(201) .body_ok(/'authtest2'/); }); - it('access test-auth-allow', function() { + test('access test-auth-allow', () => { return server2.getPackage('test-auth-allow') .status(403) .body_error('i don\'t know anything about you'); }); - it('access test-auth-deny', function() { + test('access test-auth-deny', () => { return server2.getPackage('test-auth-deny') .status(403) .body_error('i don\'t know anything about you'); }); - it('access test-auth-regular', function() { + test('access test-auth-regular', () => { return server2.getPackage('test-auth-regular') .status(404) .body_error('no such package available'); }); }); - after(function() { + afterAll(function() { server2.authstr = authstr; }); }); -}; - +} diff --git a/test/functional/plugins/middleware.spec.js b/test/functional/plugins/middleware.spec.js index 54f53a826..cfff827f9 100644 --- a/test/functional/plugins/middleware.spec.js +++ b/test/functional/plugins/middleware.spec.js @@ -6,8 +6,8 @@ require('../lib/startup'); module.exports = function () { const server2 = process.server2; - describe('middlewares', function() { - it('should serve the registered route', function() { + describe('middlewares', () => { + test('should serve the registered route', () => { return server2.request({ uri: '/test/route', method: 'GET' diff --git a/test/functional/readme/readme.spec.js b/test/functional/readme/readme.spec.js index f8e8f25aa..0a8ee76c1 100644 --- a/test/functional/readme/readme.spec.js +++ b/test/functional/readme/readme.spec.js @@ -1,17 +1,10 @@ -/** - * Created by jpicado on 7/24/17. - */ -'use strict'; +import assert from 'assert'; -const assert = require('assert'); - -module.exports = function() { - let server = process.server; - let server2 = process.server2; +export default function (server, server2) { describe('should test readme', () => { - before(function() { + beforeAll(function() { return server.request({ uri: '/readme-test', headers: { @@ -22,7 +15,7 @@ module.exports = function() { }).status(201); }); - it('add pkg', function() {}); + test('add pkg', () => {}); describe('should check readme file', () => { const matchReadme = (server) => { @@ -33,14 +26,14 @@ module.exports = function() { }); }; - it('server1 - readme', function() { + test('server1 - readme', () => { return matchReadme(server); }); - it('server2 - readme', function() { + test('server2 - readme', () => { return matchReadme(server2); }); }); }); -}; +} diff --git a/test/functional/sanity/incomplete.js b/test/functional/sanity/incomplete.js index b88bd16fe..b2905b2be 100644 --- a/test/functional/sanity/incomplete.js +++ b/test/functional/sanity/incomplete.js @@ -1,6 +1,4 @@ -'use strict'; - -let assert = require('assert'); +import assert from 'assert'; const defaultPkg = { 'name': 'testexp-incomplete', @@ -24,21 +22,19 @@ const defaultPkg = { }, }; -module.exports = function () { - const server = process.server; - const express = process.express; +export default function (server, express) { const ddd = ['content-length', 'chunked']; - describe('test send incomplete packages', function () { + describe('test send incomplete packages', () => { - before(function () { + beforeAll(function () { express.get('/testexp-incomplete', function (_, res) { res.send(defaultPkg); }); }); ddd.forEach(function (type) { - it('should not store tarballs / ' + type, function (callback) { + test('should not store tarballs / ' + type, callback => { let called; express.get('/testexp-incomplete/-/' + type + '.tar.gz', function (_, response) { if (called) { @@ -79,5 +75,4 @@ module.exports = function () { }); }); }); -}; - +} diff --git a/test/functional/sanity/mirror.js b/test/functional/sanity/mirror.js index 02ff3388a..9fa589e2c 100644 --- a/test/functional/sanity/mirror.js +++ b/test/functional/sanity/mirror.js @@ -1,15 +1,11 @@ -'use strict'; +import assert from 'assert'; +import {readFile} from '../lib/test.utils'; -const assert = require('assert'); -const util = require('../lib/test.utils'); +const getBinary = () => readFile('../fixtures/binary'); -const getBinary = () => util.readFile('../fixtures/binary'); +export default function (server, server2) { -module.exports = function () { - let server = process.server; - let server2 = process.server2; - - it('testing anti-loop', function () { + test('testing anti-loop', () => { return server2.getPackage('testloop') .status(404) .body_error(/no such package/); @@ -19,39 +15,39 @@ module.exports = function () { let prefix = pkg + ': '; pkg = 'test' + pkg; - describe(pkg, function () { - before(function () { + describe(pkg, () => { + beforeAll(function () { return server.putPackage(pkg, require('../fixtures/package')(pkg)) .status(201) .body_ok(/created new package/); }); - it(prefix + 'creating new package', function () {}); + test(prefix + 'creating new package', () => {}); - describe(pkg, function () { - before(function () { + describe(pkg, () => { + beforeAll(function () { return server.putVersion(pkg, '0.1.1', require('../fixtures/package')(pkg)) .status(201) .body_ok(/published/); }); - it(prefix + 'uploading new package version', function () {}); + test(prefix + 'uploading new package version', () => {}); - it(prefix + 'uploading incomplete tarball', function () { + test(prefix + 'uploading incomplete tarball', () => { return server.putTarballIncomplete(pkg, pkg + '.bad', getBinary(), 3000); }); - describe('tarball', function () { - before(function () { + describe('tarball', () => { + beforeAll(function () { return server.putTarball(pkg, pkg + '.file', getBinary()) .status(201) .body_ok(/.*/); }); - it(prefix + 'uploading new tarball', function () { + test(prefix + 'uploading new tarball', () => { }); - it(prefix + 'downloading tarball from server1', function () { + test(prefix + 'downloading tarball from server1', () => { return server.getTarball(pkg, pkg + '.file') .status(200) .then(function (body) { diff --git a/test/functional/sanity/nullstorage.js b/test/functional/sanity/nullstorage.js index d9618985d..7ca9aa28d 100644 --- a/test/functional/sanity/nullstorage.js +++ b/test/functional/sanity/nullstorage.js @@ -1,46 +1,40 @@ -'use strict'; - -require('../lib/startup'); - -const assert = require('assert'); -const crypto = require('crypto'); -const util = require('../lib/test.utils'); +import assert from 'assert'; +import crypto from 'crypto'; +import {readFile} from '../lib/test.utils'; function getBinary() { - return util.readFile('../fixtures/binary'); + return readFile('../fixtures/binary'); } -module.exports = function() { - const server = process.server; - const server2 = process.server2; +export default function (server, server2) { - it('trying to fetch non-existent package / null storage', function() { + test('trying to fetch non-existent package / null storage', () => { return server.getPackage('test-nullstorage-nonexist') .status(404) .body_error(/no such package/); }); - describe('test-nullstorage on server2', function() { - before(function() { + describe('test-nullstorage on server2', () => { + beforeAll(function() { return server2.addPackage('test-nullstorage2'); }); - it('creating new package - server2', function() {/* test for before() */}); + test('creating new package - server2', () => {/* test for before() */}); - it('downloading non-existent tarball', function() { + test('downloading non-existent tarball', () => { return server.getTarball('test-nullstorage2', 'blahblah') .status(404) .body_error(/no such file/); }); - describe('tarball', function() { - before(function() { + describe('tarball', () => { + beforeAll(function() { return server2.putTarball('test-nullstorage2', 'blahblah', getBinary()) .status(201) .body_ok(/.*/); }); - before(function() { + beforeAll(function() { let pkg = require('../fixtures/package')('test-nullstorage2'); pkg.dist.shasum = crypto.createHash('sha1').update(getBinary()).digest('hex'); return server2.putVersion('test-nullstorage2', '0.0.1', pkg) @@ -48,9 +42,9 @@ module.exports = function() { .body_ok(/published/); }); - it('uploading new tarball', function() {/* test for before() */}); + test('uploading new tarball', () => {/* test for before() */}); - it('downloading newly created tarball', function() { + test('downloading newly created tarball', () => { return server.getTarball('test-nullstorage2', 'blahblah') .status(200) .then(function(body) { @@ -58,7 +52,7 @@ module.exports = function() { }); }); - it('downloading newly created package', function() { + test('downloading newly created package', () => { return server.getPackage('test-nullstorage2') .status(200) .then(function(body) { @@ -70,5 +64,4 @@ module.exports = function() { }); }); }); -}; - +} diff --git a/test/functional/sanity/racycrash.js b/test/functional/sanity/racycrash.js index b515155d7..6e5cd0dd0 100644 --- a/test/functional/sanity/racycrash.js +++ b/test/functional/sanity/racycrash.js @@ -1,15 +1,11 @@ -'use strict'; +import assert from 'assert'; -const assert = require('assert'); +export default function(server, express) { -module.exports = function() { - const server = process.server; - const express = process.express; - - describe('test for unexpected client hangs', function() { + describe('test for unexpected client hangs', () => { let on_tarball; - before(function() { + beforeAll(function() { express.get('/testexp-racycrash', function(request, response) { response.send({ 'name': 'testexp-racycrash', @@ -31,7 +27,7 @@ module.exports = function() { }); }); - it('should not crash on error if client disconnects', function(callback) { + test('should not crash on error if client disconnects', callback => { on_tarball = function(res) { res.header('content-length', 1e6); res.write('test test test\n'); @@ -57,7 +53,7 @@ module.exports = function() { } }); - it('should not store tarball', function() { + test('should not store tarball', () => { on_tarball = function(res) { res.socket.destroy(); }; diff --git a/test/functional/sanity/security.js b/test/functional/sanity/security.js index 7ff74bd4b..4ebc1111b 100644 --- a/test/functional/sanity/security.js +++ b/test/functional/sanity/security.js @@ -1,28 +1,25 @@ -'use strict'; +import assert from 'assert'; -const assert = require('assert'); +export default function(server) { -module.exports = function () { - let server = process.server; - - describe('Security', function () { - before(function () { + describe('Security', () => { + beforeAll(function () { return server.addPackage('testpkg-sec'); }); - it('bad pkg #1', function () { + test('bad pkg #1', () => { return server.getPackage('package.json') .status(403) .body_error(/invalid package/); }); - it('bad pkg #2', function () { + test('bad pkg #2', () => { return server.getPackage('__proto__') .status(403) .body_error(/invalid package/); }); - it('__proto__, connect stuff', function () { + test('__proto__, connect stuff', () => { return server.request({uri: '/testpkg-sec?__proto__=1'}) .then(function (body) { // test for NOT outputting stack trace @@ -33,36 +30,36 @@ module.exports = function () { }); }); - it('do not return package.json as an attachment', function () { + test('do not return package.json as an attachment', () => { return server.request({uri: '/testpkg-sec/-/package.json'}) .status(403) .body_error(/invalid filename/); }); - it('silly things - reading #1', function () { + test('silly things - reading #1', () => { return server.request({uri: '/testpkg-sec/-/../../../../../../../../etc/passwd'}) .status(404); }); - it('silly things - reading #2', function () { + test('silly things - reading #2', () => { return server.request({uri: '/testpkg-sec/-/%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2fetc%2fpasswd'}) .status(403) .body_error(/invalid filename/); }); - it('silly things - writing #1', function () { + test('silly things - writing #1', () => { return server.putTarball('testpkg-sec', 'package.json', '{}') .status(403) .body_error(/invalid filename/); }); - it('silly things - writing #3', function () { + test('silly things - writing #3', () => { return server.putTarball('testpkg-sec', 'node_modules', '{}') .status(403) .body_error(/invalid filename/); }); - it('silly things - writing #4', function () { + test('silly things - writing #4', () => { return server.putTarball('testpkg-sec', '../testpkg.tgz', '{}') .status(403) .body_error(/invalid filename/); diff --git a/test/functional/tags/addtag.spec.js b/test/functional/tags/addtag.spec.js index 2f989ade8..b4f2481b2 100644 --- a/test/functional/tags/addtag.spec.js +++ b/test/functional/tags/addtag.spec.js @@ -1,17 +1,14 @@ -'use strict'; +import {readFile} from '../lib/test.utils'; -const util = require('../lib/test.utils'); -const readTags = () => util.readFile('../fixtures/publish.json5'); +const readTags = () => readFile('../fixtures/publish.json5'); -module.exports = function() { - let server = process.server; - - it('add tag - 404', function() { +export default function(server) { + test('add tag - 404', () => { return server.addTag('testpkg-tag', 'tagtagtag', '0.0.1').status(404).body_error(/no such package/); }); - describe('addtag', function() { - before(function() { + describe('addtag', () => { + beforeAll(function() { return server.putPackage('testpkg-tag', eval( '(' + readTags() .toString('utf8') @@ -21,26 +18,26 @@ module.exports = function() { )).status(201); }); - it('add testpkg-tag', function() { + test('add testpkg-tag', () => { // TODO: ? }); - it('add tag - bad ver', function() { + test('add tag - bad ver', () => { return server.addTag('testpkg-tag', 'tagtagtag', '0.0.1-x') .status(404) .body_error(/version doesn't exist/); }); - it('add tag - bad tag', function() { + test('add tag - bad tag', () => { return server.addTag('testpkg-tag', 'tag/tag/tag', '0.0.1-x') .status(403) .body_error(/invalid tag/); }); - it('add tag - good', function() { + test('add tag - good', () => { return server.addTag('testpkg-tag', 'tagtagtag', '0.0.1') .status(201) .body_ok(/tagged/); }); }); -}; +} diff --git a/test/functional/tags/preserve_tags.spec.js b/test/functional/tags/preserve_tags.spec.js index 8248faf5d..dea544972 100644 --- a/test/functional/tags/preserve_tags.spec.js +++ b/test/functional/tags/preserve_tags.spec.js @@ -1,16 +1,10 @@ -'use strict'; - -const assert = require('assert'); -const utils = require ('../lib/test.utils'); - -module.exports = function() { - let server = process.server; - let server2 = process.server2; - let express = process.express; +import assert from 'assert'; +import {generateSha} from '../lib/test.utils'; +export default function(server, server2, express) { describe('should test preserve tags when publishing something', () => { - before(function() { + beforeAll(function() { return server.request({ uri: '/testpkg-preserve', headers: { @@ -21,7 +15,7 @@ module.exports = function() { }).status(201); }); - it('add new package', function() {}); + test('add new package', () => {}); describe('should check sha integrity', () => { @@ -30,15 +24,15 @@ module.exports = function() { .status(200) .then(function(body) { // not real sha due to utf8 conversion - assert.strictEqual(utils.generateSha(body), '8ee7331cbc641581b1a8cecd9d38d744a8feb863'); + assert.strictEqual(generateSha(body), '8ee7331cbc641581b1a8cecd9d38d744a8feb863'); }); }; - it('server1 should match with sha key from published package', () => { + test('server1 should match with sha key from published package', () => { return matchTarBallSha(server); }); - it('server2 should match with sha key from published packagel', () => { + test('server2 should match with sha key from published packagel', () => { matchTarBallSha(server2); }); }); @@ -55,16 +49,16 @@ module.exports = function() { }); }; - it('server1 should be able to match latest dist-tags correctly', () => { + test('server1 should be able to match latest dist-tags correctly', () => { return matchDisTags(server, '55551'); }); - it('server2 should be able to match latest dist-tags correctly', function() { + test('server2 should be able to match latest dist-tags correctly', () => { return matchDisTags(server2, '55552'); }); }); - describe('should test search', function() { + describe('should test search', () => { const check = (obj) => { obj['testpkg-preserve'].time.modified = '2014-10-02T07:07:51.000Z'; assert.deepEqual(obj['testpkg-preserve'], @@ -92,19 +86,19 @@ module.exports = function() { }); }; - before(function() { + beforeAll(function() { express.get('/-/all', (req, res) => { res.send({}); }); }); - it('server1 - search', () => { + test('server1 - search', () => { return server.request({uri: '/-/all'}) .status(200) .then(check); }); - it('server2 - search', () => { + test('server2 - search', () => { return server2.request({uri: '/-/all'}) .status(200) .then(check); @@ -112,4 +106,4 @@ module.exports = function() { }); }); -}; +} diff --git a/test/functional/tags/tags.js b/test/functional/tags/tags.spec.js similarity index 82% rename from test/functional/tags/tags.js rename to test/functional/tags/tags.spec.js index ec45eaf04..47661e156 100644 --- a/test/functional/tags/tags.js +++ b/test/functional/tags/tags.spec.js @@ -1,30 +1,28 @@ -'use strict'; -const assert = require('assert'); -const _ = require('lodash'); -const util = require('../lib/test.utils'); -const readTags = () => util.readFile('../fixtures/tags.json'); +import _ from 'lodash'; +import assert from 'assert'; +import {readFile} from '../lib/test.utils'; -module.exports = function() { - let server = process.server; - let express = process.express; +const readTags = () => readFile('../fixtures/tags.json'); - it('tags - testing for 404', function() { +export default function(server, express) { + + test('tags - testing for 404', () => { return server.getPackage('testexp_tags') // shouldn't exist yet .status(404) .body_error(/no such package/); }); - describe('tags', function() { - before(function() { + describe('tags', () => { + beforeAll(function() { express.get('/testexp_tags', function(req, res) { let f = readTags().toString().replace(/__NAME__/g, 'testexp_tags'); res.send(JSON.parse(f)); }); }); - it('fetching package again', function() { + test('fetching package again', () => { return server.getPackage('testexp_tags') .status(200) .then(function(body) { @@ -38,7 +36,7 @@ module.exports = function() { const versions = ['0.1.1alpha', '0.1.1-alpha', '0000.00001.001-alpha']; versions.forEach(function(ver) { - it('fetching '+ver, function() { + test('fetching '+ver, () => { return server.request({uri: '/testexp_tags/'+ver}) .status(200) .then(function(body) { @@ -48,9 +46,9 @@ module.exports = function() { }); }); - describe('dist-tags methods', function() { + describe('dist-tags methods', () => { - before(function() { + beforeAll(function() { express.get('/testexp_tags2', function(req, res) { let f = readTags().toString().replace(/__NAME__/g, 'testexp_tags2'); @@ -60,11 +58,11 @@ module.exports = function() { }); // populate cache - before(function() { + beforeAll(function() { return server.getPackage('testexp_tags2').status(200); }); - it('fetching tags', function() { + test('fetching tags', () => { return server.request({ method: 'GET', uri: '/-/package/testexp_tags2/dist-tags', @@ -77,7 +75,7 @@ module.exports = function() { }); }); - it('merging tags', function() { + test('merging tags', () => { return server.request({ method: 'POST', uri: '/-/package/testexp_tags2/dist-tags', @@ -101,7 +99,7 @@ module.exports = function() { }); }); - it('should add a dist-tag called foo', function() { + test('should add a dist-tag called foo', () => { return server.request({ method: 'PUT', uri: '/-/package/testexp_tags2/dist-tags/foo', @@ -122,7 +120,7 @@ module.exports = function() { }); }); - it('should remove a dis-tag called quux', function() { + test('should remove a dis-tag called quux', () => { return server.request({ method: 'DELETE', uri: '/-/package/testexp_tags2/dist-tags/latest', @@ -142,7 +140,7 @@ module.exports = function() { }); }); - it('should remove a dis-tag called foo', function() { + test('should remove a dis-tag called foo', () => { return server.request({ method: 'DELETE', uri: '/-/package/testexp_tags2/dist-tags/foo', @@ -155,7 +153,7 @@ module.exports = function() { latest: '1.1.0', "quux": "0.1.0" }; - + assert.deepEqual(body, expected); }); }); diff --git a/test/functional/uplink.auth.spec.js b/test/functional/uplink.auth.spec.js index 69dbe4c80..07967af0b 100644 --- a/test/functional/uplink.auth.spec.js +++ b/test/functional/uplink.auth.spec.js @@ -1,14 +1,12 @@ -'use strict'; - -const uplinkStorage = require('../../src/lib/up-storage'); -const assert = require('assert'); +import assert from 'assert'; +import ProxyStorage from '../../src/lib/up-storage'; function createUplink(config) { const defaultConfig = { url: 'https://registry.npmjs.org/' }; let mergeConfig = Object.assign({}, defaultConfig, config); - return new uplinkStorage(mergeConfig, {}); + return new ProxyStorage(mergeConfig, {}); } function setHeaders(config, headers) { @@ -20,11 +18,11 @@ function setHeaders(config, headers) { }); } -module.exports = function () { +export default function () { - describe('uplink auth test', function () { + describe('uplink auth test', () => { - it('if set headers empty should return default headers', function () { + test('if set headers empty should return default headers', () => { const headers = setHeaders(); const keys = Object.keys(headers); const keysExpected = ['Accept', 'Accept-Encoding', 'User-Agent']; @@ -33,7 +31,7 @@ module.exports = function () { assert.equal(keys.length, 3); }); - it('if assigns value invalid to attribute auth', function () { + test('if assigns value invalid to attribute auth', () => { const fnError = function () { setHeaders({ auth: '' @@ -43,7 +41,7 @@ module.exports = function () { assert.throws(fnError, 'Auth invalid'); }); - it('if assigns the header authorization', function () { + test('if assigns the header authorization', () => { const headers = setHeaders({}, { 'authorization': 'basic Zm9vX2Jhcg==' }); @@ -52,20 +50,23 @@ module.exports = function () { assert.equal(headers['authorization'], 'basic Zm9vX2Jhcg=='); }); - it('if assigns headers authorization and token the header precedes', function () { - const headers = setHeaders({ - auth: { - type: 'bearer', - token: 'tokenBearer' - } - }, { - 'authorization': 'basic tokenBasic' - }); + test( + 'if assigns headers authorization and token the header precedes', + () => { + const headers = setHeaders({ + auth: { + type: 'bearer', + token: 'tokenBearer' + } + }, { + 'authorization': 'basic tokenBasic' + }); - assert.equal(headers['authorization'], 'basic tokenBasic'); - }); + assert.equal(headers['authorization'], 'basic tokenBasic'); + } + ); - it('set type auth basic', function () { + test('set type auth basic', () => { const headers = setHeaders({ auth: { type: 'basic', @@ -77,7 +78,7 @@ module.exports = function () { assert.equal(headers['authorization'], 'Basic Zm9vX2Jhcg=='); }); - it('set type auth bearer', function () { + test('set type auth bearer', () => { const headers = setHeaders({ auth: { type: 'bearer', @@ -89,8 +90,8 @@ module.exports = function () { assert.equal(headers['authorization'], 'Bearer Zm9vX2Jhcf==='); }); - it('set auth type invalid', function () { - const fnError = function() { + test('set auth type invalid', () => { + const fnError = function() { setHeaders({ auth: { type: 'null', @@ -98,11 +99,11 @@ module.exports = function () { } }) }; - + assert.throws(fnError, `Auth type 'null' not allowed`); }); - it('set auth with NPM_TOKEN', function () { + test('set auth with NPM_TOKEN', () => { process.env.NPM_TOKEN = 'myToken'; const headers = setHeaders({ auth: { @@ -114,7 +115,7 @@ module.exports = function () { delete process.env.NPM_TOKEN; }); - it('set auth with token name and assigns in env', function () { + test('set auth with token name and assigns in env', () => { process.env.NPM_TOKEN_TEST = 'myTokenTest'; const headers = setHeaders({ auth: { @@ -128,7 +129,7 @@ module.exports = function () { }); - it('if token not set', function () { + test('if token not set', () => { const fnError = function() { setHeaders({ auth: { @@ -140,5 +141,4 @@ module.exports = function () { assert.throws(fnError, 'Token is required'); }); }); -}; - +} diff --git a/test/functional/uplink.cache.spec.js b/test/functional/uplink.cache.spec.js index cd009e18b..e98a97f8e 100644 --- a/test/functional/uplink.cache.spec.js +++ b/test/functional/uplink.cache.spec.js @@ -1,14 +1,11 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const assert = require('assert'); -const crypto = require('crypto'); - -const util = require('./lib/test.utils'); +import fs from 'fs'; +import path from 'path'; +import assert from 'assert'; +import crypto from 'crypto'; +import {readFile} from './lib/test.utils'; function getBinary() { - return util.readFile('../fixtures/binary'); + return readFile('../fixtures/binary'); } const STORAGE = 'store/test-storage3'; @@ -20,26 +17,23 @@ function isCached(pkgName, tarballName) { return fs.existsSync(path.join(__dirname, STORAGE, pkgName, tarballName)); } -module.exports = function() { - const server = process.server; - const server2 = process.server2; - const server3 = process.server3; +export default function (server, server2, server3) { - describe('storage tarball cache test', function() { + describe('storage tarball cache test', () => { //more info #131 - before(function () { + beforeAll(function () { return server.addPackage(PKG_GH131); }); - before(function () { + beforeAll(function () { return server.putTarball(PKG_GH131, TARBALL, getBinary()) .status(201) .body_ok(/.*/); }); - before(function () { + beforeAll(function () { const pkg = require('./fixtures/package')(PKG_GH131); pkg.dist.shasum = crypto.createHash('sha1').update(getBinary()).digest('hex'); @@ -48,31 +42,31 @@ module.exports = function() { .body_ok(/published/); }); - before(function () { + beforeAll(function () { return server3.getPackage(PKG_GH131) .status(200); }); - before(function () { + beforeAll(function () { return server3.getTarball(PKG_GH131, TARBALL) .status(200); }); - it('should be caching packages from uplink server1', function () { + test('should be caching packages from uplink server1', () => { assert.equal(isCached(PKG_GH131, TARBALL), true); }); - before(function () { + beforeAll(function () { return server2.addPackage(PKG_GH1312); }); - before(function () { + beforeAll(function () { return server2.putTarball(PKG_GH1312, TARBALL, getBinary()) .status(201) .body_ok(/.*/); }); - before(function () { + beforeAll(function () { const pkg = require('./fixtures/package')(PKG_GH1312); pkg.dist.shasum = crypto.createHash('sha1').update(getBinary()).digest('hex'); @@ -81,20 +75,19 @@ module.exports = function() { .body_ok(/published/); }); - before(function () { + beforeAll(function () { return server3.getPackage(PKG_GH1312) .status(200); }); - before(function () { + beforeAll(function () { return server3.getTarball(PKG_GH1312, TARBALL) .status(200); }); - it('must not be caching packages from uplink server2', function () { + test('must not be caching packages from uplink server2', () => { assert.equal(isCached(PKG_GH1312, TARBALL), false); }); }); -}; - +}