2021-03-14 02:42:46 -05:00
|
|
|
import { DIST_TAGS, LATEST } from '../../../src/lib/constants';
|
2019-08-10 06:38:06 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Verify whether the package tag match with the desired version.
|
|
|
|
*/
|
|
|
|
export function getTaggedVersionFromPackage(pkg, pkgName, tag: string = LATEST, version: string) {
|
2021-03-14 02:42:46 -05:00
|
|
|
// extract the tagged version
|
|
|
|
const taggedVersion = pkg[DIST_TAGS][tag];
|
|
|
|
expect(taggedVersion).toBeDefined();
|
|
|
|
expect(taggedVersion).toEqual(version);
|
2019-08-10 06:38:06 -05:00
|
|
|
|
2021-03-14 02:42:46 -05:00
|
|
|
// the version must exist
|
|
|
|
const latestPkg = pkg.versions[taggedVersion];
|
|
|
|
expect(latestPkg).toBeDefined();
|
|
|
|
// the name must match
|
|
|
|
expect(latestPkg.name).toEqual(pkgName);
|
2019-08-10 06:38:06 -05:00
|
|
|
|
2021-03-14 02:42:46 -05:00
|
|
|
return latestPkg;
|
2019-08-10 06:38:06 -05:00
|
|
|
}
|