mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
test(unit): add unit test for publish and unpublish
This commit is contained in:
parent
c08f257bf1
commit
885345f4cf
2 changed files with 90 additions and 0 deletions
|
@ -4,6 +4,7 @@ import path from 'path';
|
|||
import rimraf from 'rimraf';
|
||||
|
||||
import configDefault from './partials/config';
|
||||
import publishMetadata from './partials/publish-api';
|
||||
import Config from '../../src/lib/config';
|
||||
import Storage from '../../src/lib/storage';
|
||||
import Auth from '../../src/lib/auth';
|
||||
|
@ -446,4 +447,40 @@ describe('endpoint unit test', () => {
|
|||
|
||||
});
|
||||
|
||||
describe('should test publish api', () => {
|
||||
test('should publish a new package', (done) => {
|
||||
request(app)
|
||||
.put('/@scope%2fpk1-test')
|
||||
.set('content-type', 'application/json')
|
||||
.send(JSON.stringify(publishMetadata))
|
||||
.expect(201)
|
||||
.end(function(err, res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
expect(res.body.ok).toBeDefined();
|
||||
expect(res.body.success).toBeDefined();
|
||||
expect(res.body.success).toBeTruthy();
|
||||
expect(res.body.ok).toMatch(/created new package/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('should unpublish a new package', (done) => {
|
||||
//FUTURE: for some reason it does not remove the scope folder
|
||||
request(app)
|
||||
.del('/@scope%2fpk1-test/-rev/4-6abcdb4efd41a576')
|
||||
.set('content-type', 'application/json')
|
||||
.expect(201)
|
||||
.end(function(err, res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
expect(res.body.ok).toBeDefined();
|
||||
expect(res.body.ok).toMatch(/package removed/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
53
test/unit/partials/publish-api.js
Normal file
53
test/unit/partials/publish-api.js
Normal file
|
@ -0,0 +1,53 @@
|
|||
const json = {
|
||||
"_id": "@scope\/pk1-test",
|
||||
"name": "@scope\/pk1-test",
|
||||
"description": "",
|
||||
"dist-tags": {
|
||||
"latest": "1.0.6"
|
||||
},
|
||||
"versions": {
|
||||
"1.0.6": {
|
||||
"name": "@scope\/pk1-test",
|
||||
"version": "1.0.6",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [
|
||||
|
||||
],
|
||||
"author": {
|
||||
"name": "Juan Picado",
|
||||
"email": "juan@jotadeveloper.com"
|
||||
},
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"verdaccio": "^2.7.2"
|
||||
},
|
||||
"readme": "# test",
|
||||
"readmeFilename": "README.md",
|
||||
"_id": "@scope\/pk1-test@1.0.6",
|
||||
"_npmVersion": "5.5.1",
|
||||
"_nodeVersion": "8.7.0",
|
||||
"_npmUser": {
|
||||
|
||||
},
|
||||
"dist": {
|
||||
"integrity": "sha512-6gHiERpiDgtb3hjqpQH5\/i7zRmvYi9pmCjQf2ZMy3QEa9wVk9RgdZaPWUt7ZOnWUPFjcr9cmE6dUBf+XoPoH4g==",
|
||||
"shasum": "2c03764f651a9f016ca0b7620421457b619151b9",
|
||||
"tarball": "http:\/\/localhost:5555\/@scope\/pk1-test\/-\/@scope\/pk1-test-1.0.6.tgz"
|
||||
}
|
||||
}
|
||||
},
|
||||
"readme": "# test",
|
||||
"_attachments": {
|
||||
"@scope\/pk1-test-1.0.6.tgz": {
|
||||
"content_type": "application\/octet-stream",
|
||||
"data": "H4sIAAAAAAAAE+2W32vbMBDH85y\/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo\/\/79KPeQsnIw5KUDX\/9IOvurLuz\/DHSjK\/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF\/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI\/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS\/pLQe+D+FIv\/agIWI6GX66kFuIhT+1gDjrp\/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0\/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi\/IHpU9fz3\/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6\/f88f\/Pu47zomiPk2Lv\/dOv8h+P\/34\/D\/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=",
|
||||
"length": 512
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = json;
|
Loading…
Reference in a new issue