Skip to content

Commit

Permalink
fix: add unit test for unpkgAliasPath
Browse files Browse the repository at this point in the history
  • Loading branch information
chilingling committed May 14, 2024
1 parent 91a0cf4 commit 7090519
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions test/fixtures/@cnpm/test-find-entry/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@cnpm/test-find-entry",
"version": "1.0.0",
"description": "cnpmcore local test package",
"main": "index.js",
"scripts": {
"test": "echo \"hello\""
},
"author": "",
"license": "MIT"
}
Original file line number Diff line number Diff line change
Expand Up @@ -352,5 +352,41 @@ describe('test/port/controller/PackageVersionFileController/listFiles.test.ts',
assert.equal(called, 1);
assert.equal(resList.filter(res => res.status === 409 && res.body.error === '[CONFLICT] Package version file sync is currently in progress. Please try again later.').length, 1);
});
it('should redirect to possible entry', async () => {
const pkg = await TestUtil.getFullPackage({
name: '@cnpm/test-find-entry',
version: '1.0.0',
versionObject: {
description: 'work with utf8mb4 💩, 𝌆 utf8_unicode_ci, foo𝌆bar 🍻',
},
});

await app.httpRequest()
.put(`/${pkg.name}`)
.set('authorization', publisher.authorization)
.set('user-agent', publisher.ua)
.send(pkg)
.expect(201);

await app.httpRequest()
.get(`/${pkg.name}/1.0.0/files/es/array/at`)
.expect(302)
.expect('location', `/${pkg.name}/1.0.0/files/es/array/at.js`);

await app.httpRequest()
.get(`/${pkg.name}/1.0.0/files/es/array`)
.expect(302)
.expect('location', `/${pkg.name}/1.0.0/files/es/array/index.js`);

await app.httpRequest()
.get(`/${pkg.name}/1.0.0/files/es/json/test`)
.expect(302)
.expect('location', `/${pkg.name}/1.0.0/files/es/json/test.json`);

await app.httpRequest()
.get(`/${pkg.name}/1.0.0/files/es/json`)
.expect(302)
.expect('location', `/${pkg.name}/1.0.0/files/es/json/index.json`);
});
});
});

0 comments on commit 7090519

Please sign in to comment.