2017-07-25 20:14:51 +02:00
|
|
|
|
2017-12-02 09:52:40 +01:00
|
|
|
import assert from 'assert';
|
|
|
|
import {generateSha} from '../lib/test.utils';
|
2017-07-25 20:14:51 +02:00
|
|
|
|
2017-12-02 09:52:40 +01:00
|
|
|
export default function(server, server2) {
|
2017-07-25 20:14:51 +02:00
|
|
|
|
2017-12-02 09:52:40 +01:00
|
|
|
describe('test-scoped', () => {
|
|
|
|
beforeAll(function() {
|
2017-07-25 20:14:51 +02:00
|
|
|
return server.request({
|
|
|
|
uri: '/@test%2fscoped',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
},
|
|
|
|
method: 'PUT',
|
|
|
|
json: require('./scoped.json'),
|
|
|
|
}).status(201);
|
|
|
|
});
|
|
|
|
|
2017-12-02 09:52:40 +01:00
|
|
|
test('should publish scope package', () => {});
|
2017-07-25 20:14:51 +02:00
|
|
|
|
|
|
|
describe('should get scoped packages tarball', () => {
|
|
|
|
const uploadScopedTarBall = (server) => {
|
|
|
|
return server.getTarball('@test/scoped', 'scoped-1.0.0.tgz')
|
|
|
|
.status(200)
|
|
|
|
.then(function(body) {
|
|
|
|
// not real sha due to utf8 conversion
|
2017-12-02 09:52:40 +01:00
|
|
|
assert.strictEqual(generateSha(body),
|
2017-07-25 20:14:51 +02:00
|
|
|
'6e67b14e2c0e450b942e2bc8086b49e90f594790');
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2017-12-02 09:52:40 +01:00
|
|
|
test('should be a scoped tarball from server1', () => {
|
2017-07-25 20:14:51 +02:00
|
|
|
return uploadScopedTarBall(server);
|
|
|
|
});
|
|
|
|
|
2017-12-02 09:52:40 +01:00
|
|
|
test('should be a scoped tarball from server2', () => {
|
2017-07-25 20:14:51 +02:00
|
|
|
return uploadScopedTarBall(server2);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2017-12-02 09:52:40 +01:00
|
|
|
describe('should retrieve scoped packages', () => {
|
2017-07-25 20:14:51 +02:00
|
|
|
const testScopePackage = (server, port) => server.getPackage('@test/scoped')
|
|
|
|
.status(200)
|
|
|
|
.then(function(body) {
|
|
|
|
assert.equal(body.name, '@test/scoped');
|
|
|
|
assert.equal(body.versions['1.0.0'].name, '@test/scoped');
|
|
|
|
assert.equal(body.versions['1.0.0'].dist.tarball,
|
|
|
|
`http://localhost:${port}/@test%2fscoped/-/scoped-1.0.0.tgz`);
|
|
|
|
assert.deepEqual(body['dist-tags'], {latest: '1.0.0'});
|
|
|
|
});
|
|
|
|
|
2017-12-02 09:52:40 +01:00
|
|
|
test('scoped package on server1', () => {
|
2017-07-25 20:14:51 +02:00
|
|
|
return testScopePackage(server, '55551');
|
|
|
|
});
|
|
|
|
|
2017-12-02 09:52:40 +01:00
|
|
|
test('scoped package on server2', () => {
|
2017-07-25 20:14:51 +02:00
|
|
|
return testScopePackage(server2, '55552');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-12-02 09:52:40 +01:00
|
|
|
describe('should retrieve a scoped packages under nginx', () => {
|
|
|
|
test('should work nginx workaround', () => {
|
2017-07-25 20:14:51 +02:00
|
|
|
return server2.request({
|
|
|
|
uri: '/@test/scoped/1.0.0'
|
|
|
|
}).status(200)
|
|
|
|
.then(function(body) {
|
|
|
|
assert.equal(body.name, '@test/scoped');
|
|
|
|
assert.equal(body.dist.tarball,
|
|
|
|
'http://localhost:55552/@test%2fscoped/-/scoped-1.0.0.tgz');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-12-02 09:52:40 +01:00
|
|
|
}
|