0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-06 22:40:26 -05:00

refactor: enable incomplete test

This commit is contained in:
Juan Picado @jotadeveloper 2018-06-23 11:12:20 +02:00
parent 0fcbb8e1bd
commit 1294477ff3
No known key found for this signature in database
GPG key ID: 18AC54485952D158

View file

@ -1,4 +1,5 @@
import assert from 'assert'; import {API_ERROR, HEADER_TYPE, HTTP_STATUS} from '../../../src/lib/constants';
import {DOMAIN_SERVERS, PORT_SERVER_APP} from '../config.func';
const defaultPkg = { const defaultPkg = {
'name': 'testexp-incomplete', 'name': 'testexp-incomplete',
@ -8,7 +9,7 @@ const defaultPkg = {
'version': '0.1.0', 'version': '0.1.0',
'dist': { 'dist': {
'shasum': 'fake', 'shasum': 'fake',
'tarball': 'http://localhost:55550/testexp-incomplete/-/content-length.tar.gz', 'tarball': `http://${DOMAIN_SERVERS}:${PORT_SERVER_APP}/testexp-incomplete/-/content-length.tar.gz`,
}, },
}, },
'0.1.1': { '0.1.1': {
@ -16,14 +17,14 @@ const defaultPkg = {
'version': '0.1.1', 'version': '0.1.1',
'dist': { 'dist': {
'shasum': 'fake', 'shasum': 'fake',
'tarball': 'http://localhost:55550/testexp-incomplete/-/chunked.tar.gz', 'tarball': `http://${DOMAIN_SERVERS}:${PORT_SERVER_APP}/testexp-incomplete/-/chunked.tar.gz`,
}, },
}, },
}, },
}; };
export default function (server, express) { export default function (server, express) {
const ddd = ['content-length', 'chunked']; const listofCalls = [HEADER_TYPE.CONTENT_LENGTH, 'chunked'];
describe('test send incomplete packages', () => { describe('test send incomplete packages', () => {
@ -33,8 +34,8 @@ export default function (server, express) {
}); });
}); });
ddd.forEach(function (type) { listofCalls.forEach(function (type) {
test.skip('should not store tarballs / ' + type, callback => { test('should not store tarballs / ' + type, callback => {
let called; let called;
express.get('/testexp-incomplete/-/' + type + '.tar.gz', function (_, response) { express.get('/testexp-incomplete/-/' + type + '.tar.gz', function (_, response) {
if (called) { if (called) {
@ -43,7 +44,7 @@ export default function (server, express) {
called = true; called = true;
if (type !== 'chunked') { if (type !== 'chunked') {
response.header('content-length', 1e6); response.header(HEADER_TYPE.CONTENT_LENGTH, 1e6);
} }
response.write('test test test\n'); response.write('test test test\n');
@ -56,18 +57,18 @@ export default function (server, express) {
}); });
server.request({uri: '/testexp-incomplete/-/' + type + '.tar.gz'}) server.request({uri: '/testexp-incomplete/-/' + type + '.tar.gz'})
.status(200) .status(HTTP_STATUS.OK)
.response(function (res) { .response(function (res) {
if (type !== 'chunked') { if (type !== 'chunked') {
assert.equal(res.headers['content-length'], 1e6); expect(parseInt(res.headers[HEADER_TYPE.CONTENT_LENGTH], 10)).toBe(1e6);
} }
}).then(function (body) { }).then(function (body) {
assert(body.match(/test test test/)); expect(body).toMatch(/test test test/);
}); });
function cb() { function cb() {
server.request({uri: '/testexp-incomplete/-/' + type + '.tar.gz'}) server.request({uri: '/testexp-incomplete/-/' + type + '.tar.gz'})
.body_error('internal server error') .body_error(API_ERROR.INTERNAL_SERVER_ERROR)
.then(function () { .then(function () {
callback(); callback();
}); });