1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/test/functional/sanity/incomplete.ts
Juan Picado @jotadeveloper 66f4197236
feat: convert project to typescript (#1374)
* chore: test

* chore: add

* chore: more progress

* chore: progress in migration, fix prettier parser

* chore: reduce tsc errors

* chore: refactor storage utils types

* chore: refactor utils types

* chore: refactor local storage types

* chore: refactor config utils types

* chore: refactor tsc types

* refactor: apply eslint fix, tabs etc

* chore: fix lint errors

* test: update unit test conf to typescript setup

few test refactored to typescript

* chore: enable more unit test

migrate to typescript

* chore: migrate storage test to tsc

* chore: migrate up storage test to tsc

* refactor: enable plugin and auth test

* chore: migrate plugin loader test

* chore: update dependencies

* chore: migrate functional test to typescript

* chore: add codecove

* chore: update express

* chore: downgrade puppeteer

The latest version does not seems to work properly fine.

* chore: update dependencies
2019-07-16 08:40:01 +02:00

80 lines
2.2 KiB
TypeScript

import {API_ERROR, HEADER_TYPE, HTTP_STATUS} from '../../../src/lib/constants';
import {DOMAIN_SERVERS, PORT_SERVER_APP} from '../config.functional';
const defaultPkg = {
'name': 'testexp-incomplete',
'versions': {
'0.1.0': {
'name': 'testexp_tags',
'version': '0.1.0',
'dist': {
'shasum': 'fake',
'tarball': `http://${DOMAIN_SERVERS}:${PORT_SERVER_APP}/testexp-incomplete/-/content-length.tar.gz`,
},
},
'0.1.1': {
'name': 'testexp_tags',
'version': '0.1.1',
'dist': {
'shasum': 'fake',
'tarball': `http://${DOMAIN_SERVERS}:${PORT_SERVER_APP}/testexp-incomplete/-/chunked.tar.gz`,
},
},
},
};
export default function (server, express) {
const listofCalls = [HEADER_TYPE.CONTENT_LENGTH, 'chunked'];
describe('test send incomplete packages', () => {
beforeAll(function () {
express.get('/testexp-incomplete', function (_, res) {
res.send(defaultPkg);
});
});
listofCalls.forEach((type) => {
test(`should not store tarballs / ${type}`, callback => {
let called;
express.get(`/testexp-incomplete/-/${type}.tar.gz`, function (_, response) {
if (called) {
return response.socket.destroy();
}
called = true;
if (type !== 'chunked') {
response.header(HEADER_TYPE.CONTENT_LENGTH, 1e6);
}
response.write('test test test\n');
setTimeout(function () {
response.socket.write('200\nsss\n');
response.socket.destroy();
cb();
}, 10);
});
server.request({uri: '/testexp-incomplete/-/' + type + '.tar.gz'})
.status(HTTP_STATUS.OK)
.response(function (res) {
if (type !== 'chunked') {
expect(parseInt(res.headers[HEADER_TYPE.CONTENT_LENGTH], 10)).toBe(1e6);
}
}).then(function (body) {
expect(body).toMatch(/test test test/);
});
function cb() {
server.request({uri: '/testexp-incomplete/-/' + type + '.tar.gz'})
.body_error(API_ERROR.INTERNAL_SERVER_ERROR)
.then(function () {
callback();
});
}
});
});
});
}