2023-12-05 11:22:13 -05:00
|
|
|
import { expect } from 'chai';
|
|
|
|
import { collectPackageInfo } from '../dist/index.js';
|
|
|
|
|
|
|
|
describe('collectPackageInfo', () => {
|
|
|
|
const context = {
|
|
|
|
cwd: '',
|
|
|
|
version: 'latest',
|
|
|
|
packageManager: 'npm',
|
|
|
|
dryRun: true,
|
2023-12-05 11:23:18 -05:00
|
|
|
packages: [],
|
2023-12-05 11:22:13 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
context.packages = [];
|
2023-12-05 11:23:18 -05:00
|
|
|
});
|
2023-12-05 11:22:13 -05:00
|
|
|
|
|
|
|
it('detects astro', async () => {
|
2023-12-05 11:23:18 -05:00
|
|
|
collectPackageInfo(context, { astro: '1.0.0' }, {});
|
|
|
|
expect(context.packages).deep.equal([
|
|
|
|
{ name: 'astro', currentVersion: '1.0.0', targetVersion: 'latest' },
|
|
|
|
]);
|
2023-12-05 11:22:13 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('detects @astrojs', async () => {
|
2023-12-05 11:23:18 -05:00
|
|
|
collectPackageInfo(context, { '@astrojs/preact': '1.0.0' }, {});
|
|
|
|
expect(context.packages).deep.equal([
|
|
|
|
{ name: '@astrojs/preact', currentVersion: '1.0.0', targetVersion: 'latest' },
|
|
|
|
]);
|
2023-12-05 11:22:13 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('supports ^ prefixes', async () => {
|
2023-12-05 11:23:18 -05:00
|
|
|
collectPackageInfo(context, { astro: '^1.0.0' }, {});
|
|
|
|
expect(context.packages).deep.equal([
|
|
|
|
{ name: 'astro', currentVersion: '^1.0.0', targetVersion: 'latest' },
|
|
|
|
]);
|
2023-12-05 11:22:13 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('supports ~ prefixes', async () => {
|
2023-12-05 11:23:18 -05:00
|
|
|
collectPackageInfo(context, { astro: '~1.0.0' }, {});
|
|
|
|
expect(context.packages).deep.equal([
|
|
|
|
{ name: 'astro', currentVersion: '~1.0.0', targetVersion: 'latest' },
|
|
|
|
]);
|
2023-12-05 11:22:13 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('supports prereleases', async () => {
|
2023-12-05 11:23:18 -05:00
|
|
|
collectPackageInfo(context, { astro: '1.0.0-beta.0' }, {});
|
|
|
|
expect(context.packages).deep.equal([
|
|
|
|
{ name: 'astro', currentVersion: '1.0.0-beta.0', targetVersion: 'latest' },
|
|
|
|
]);
|
2023-12-05 11:22:13 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('ignores self', async () => {
|
2023-12-05 11:23:18 -05:00
|
|
|
collectPackageInfo(context, { '@astrojs/upgrade': '0.0.1' }, {});
|
2023-12-05 11:22:13 -05:00
|
|
|
expect(context.packages).deep.equal([]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('ignores linked packages', async () => {
|
2023-12-05 11:23:18 -05:00
|
|
|
collectPackageInfo(context, { '@astrojs/preact': 'link:../packages/preact' }, {});
|
2023-12-05 11:22:13 -05:00
|
|
|
expect(context.packages).deep.equal([]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('ignores workspace packages', async () => {
|
2023-12-05 11:23:18 -05:00
|
|
|
collectPackageInfo(context, { '@astrojs/preact': 'workspace:*' }, {});
|
2023-12-05 11:22:13 -05:00
|
|
|
expect(context.packages).deep.equal([]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('ignores github packages', async () => {
|
2023-12-05 11:23:18 -05:00
|
|
|
collectPackageInfo(context, { '@astrojs/preact': 'github:withastro/astro' }, {});
|
2023-12-05 11:22:13 -05:00
|
|
|
expect(context.packages).deep.equal([]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('ignores tag', async () => {
|
2023-12-05 11:23:18 -05:00
|
|
|
collectPackageInfo(context, { '@astrojs/preact': 'beta' }, {});
|
2023-12-05 11:22:13 -05:00
|
|
|
expect(context.packages).deep.equal([]);
|
|
|
|
});
|
|
|
|
});
|