Add tests
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import {expect, jest, test} from '@jest/globals'
|
||||
import {Change, Changes, Scorecard} from '../src/schemas'
|
||||
import {getScorecardLevels} from '../src/scorecard'
|
||||
import {Change, Changes} from '../src/schemas'
|
||||
import {getScorecardLevels, getProjectUrl} from '../src/scorecard'
|
||||
|
||||
const npmChange: Change = {
|
||||
manifest: 'package.json',
|
||||
@@ -22,8 +22,19 @@ const npmChange: Change = {
|
||||
]
|
||||
}
|
||||
|
||||
test('Can download data from deps.dev', async () => {
|
||||
test('Get scorecard from API', async () => {
|
||||
const changes: Changes = [npmChange]
|
||||
const scorecard = await getScorecardLevels(changes)
|
||||
expect(scorecard).not.toBeNull()
|
||||
})
|
||||
expect(scorecard.dependencies).toHaveLength(1)
|
||||
expect(scorecard.dependencies[0].scorecard?.score).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
test('Get project URL from deps.dev API', async () => {
|
||||
const result = await getProjectUrl(
|
||||
npmChange.ecosystem,
|
||||
npmChange.name,
|
||||
npmChange.version
|
||||
)
|
||||
expect(result).not.toBeNull()
|
||||
})
|
||||
|
||||
+2
-1
@@ -1024,7 +1024,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.getScorecardLevels = void 0;
|
||||
exports.getProjectUrl = exports.getScorecardLevels = void 0;
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
function getScorecardLevels(changes) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
@@ -1097,6 +1097,7 @@ function getProjectUrl(ecosystem, packageName, version) {
|
||||
return '';
|
||||
});
|
||||
}
|
||||
exports.getProjectUrl = getProjectUrl;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -62,7 +62,7 @@ async function getScorecard(repositoryUrl: string): Promise<ScorecardApi> {
|
||||
return scorecardResponse
|
||||
}
|
||||
|
||||
async function getProjectUrl(
|
||||
export async function getProjectUrl(
|
||||
ecosystem: string,
|
||||
packageName: string,
|
||||
version: string
|
||||
|
||||
Reference in New Issue
Block a user