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.

78 lines
2.3 KiB
JavaScript
Raw Normal View History

import * as assert from 'node:assert/strict';
import { beforeEach, describe, it } from 'node:test';
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' }, {});
assert.deepEqual(context.packages, [
2023-12-05 11:23:18 -05:00
{ 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' }, {});
assert.deepEqual(context.packages, [
2023-12-05 11:23:18 -05:00
{ 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' }, {});
assert.deepEqual(context.packages, [
2023-12-05 11:23:18 -05:00
{ 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' }, {});
assert.deepEqual(context.packages, [
2023-12-05 11:23:18 -05:00
{ 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' }, {});
assert.deepEqual(context.packages, [
2023-12-05 11:23:18 -05:00
{ 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' }, {});
assert.deepEqual(context.packages, []);
});
it('ignores linked packages', async () => {
2023-12-05 11:23:18 -05:00
collectPackageInfo(context, { '@astrojs/preact': 'link:../packages/preact' }, {});
assert.deepEqual(context.packages, []);
});
it('ignores workspace packages', async () => {
2023-12-05 11:23:18 -05:00
collectPackageInfo(context, { '@astrojs/preact': 'workspace:*' }, {});
assert.deepEqual(context.packages, []);
});
it('ignores github packages', async () => {
2023-12-05 11:23:18 -05:00
collectPackageInfo(context, { '@astrojs/preact': 'github:withastro/astro' }, {});
assert.deepEqual(context.packages, []);
});
it('ignores tag', async () => {
2023-12-05 11:23:18 -05:00
collectPackageInfo(context, { '@astrojs/preact': 'beta' }, {});
assert.deepEqual(context.packages, []);
});
});