1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-08 23:25:51 +01:00

test: remove unused var and change to toHaveLength

This commit is contained in:
vip30 2019-03-12 08:03:25 +08:00
parent 75c0e1e4ec
commit d0d74fa21b

@ -562,7 +562,7 @@ describe('endpoint unit test', () => {
});
});
describe('should test star api', () => {
describe('should test star and stars api', () => {
test('should star a package', (done) => {
request(app)
.put('/@scope%2fpk1-test')
@ -601,45 +601,47 @@ describe('endpoint unit test', () => {
done();
});
});
test('should retrieve stars list with credentials', async (done) => {
const credentials = { name: 'star_user', password: 'secretPass' };
const token = await getNewToken(request(app), credentials);
request(app)
.put('/@scope%2fpk1-test')
.set('authorization', buildToken(TOKEN_BEARER, token))
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON)
.send(JSON.stringify({
...starMetadata,
users: {
[credentials.name]: true
}
}))
.expect(HTTP_STATUS.OK).end(function(err) {
if (err) {
expect(err).toBeNull();
return done(err);
}
request(app)
.get('/-/_view/starredByUser')
.set('authorization', buildToken(TOKEN_BEARER, token))
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON)
.send(JSON.stringify({
key: [credentials.name]
}))
.expect(HTTP_STATUS.OK)
.end(function(err, res) {
if (err) {
expect(err).toBeNull();
return done(err);
}
expect(res.body.rows).toBeDefined();
expect(res.body.rows).toHaveLength(1);
done();
});
});
});
});
test('should retrieve stars list with credentials', async (done) => {
const credentials = { name: 'star_user', password: 'secretPass' };
const token = await getNewToken(request(app), credentials);
request(app)
.put('/@scope%2fpk1-test')
.set('authorization', buildToken(TOKEN_BEARER, token))
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON)
.send(JSON.stringify({
...starMetadata,
users: {
[credentials.name]: true
}
}))
.expect(HTTP_STATUS.OK).end(function(err, res) {
if (err) {
expect(err).toBeNull();
return done(err);
}
request(app)
.get('/-/_view/starredByUser')
.set('authorization', buildToken(TOKEN_BEARER, token))
.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON)
.send(JSON.stringify({
key: [credentials.name]
}))
.expect(HTTP_STATUS.OK)
.end(function(err, res) {
if (err) {
expect(err).toBeNull();
return done(err);
}
expect(res.body.rows).toBeDefined();
expect(res.body.rows.length).toBeGreaterThan(0);
done();
});
});
});
test('should unpublish a new package with credentials', async (done) => {