0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/packages/upgrade/test/verify.test.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

77 lines
2.2 KiB
JavaScript
Raw Normal View History

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: [],
};
beforeEach(() => {
context.packages = [];
2023-12-05 11:23:18 -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' },
]);
});
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' },
]);
});
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' },
]);
});
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' },
]);
});
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' },
]);
});
it('ignores self', async () => {
2023-12-05 11:23:18 -05:00
collectPackageInfo(context, { '@astrojs/upgrade': '0.0.1' }, {});
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' }, {});
expect(context.packages).deep.equal([]);
});
it('ignores workspace packages', async () => {
2023-12-05 11:23:18 -05:00
collectPackageInfo(context, { '@astrojs/preact': 'workspace:*' }, {});
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' }, {});
expect(context.packages).deep.equal([]);
});
it('ignores tag', async () => {
2023-12-05 11:23:18 -05:00
collectPackageInfo(context, { '@astrojs/preact': 'beta' }, {});
expect(context.packages).deep.equal([]);
});
});