Require the tracked FreeBSD 15.x line during install and environment checks, and align docs and skill compatibility metadata with 15.x only. --- Build: pass Tests: pass — 37 passed (2 files) --- Build: pass | Tests: pass — 2363 passed (701 files)
108 lines
2.8 KiB
TypeScript
108 lines
2.8 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
|
|
import {
|
|
getPlatform,
|
|
isRoot,
|
|
hasBrowser,
|
|
getServiceManager,
|
|
commandExists,
|
|
getNodeVersion,
|
|
getNodeMajorVersion,
|
|
parseFreeBSDMajorVersion,
|
|
checkFreeBSDVersionSupport,
|
|
} from './platform.js';
|
|
|
|
// --- getPlatform ---
|
|
|
|
describe('getPlatform', () => {
|
|
it('returns a valid platform string', () => {
|
|
const result = getPlatform();
|
|
expect(['freebsd', 'unknown']).toContain(result);
|
|
});
|
|
});
|
|
|
|
// --- isRoot ---
|
|
|
|
describe('isRoot', () => {
|
|
it('returns a boolean', () => {
|
|
expect(typeof isRoot()).toBe('boolean');
|
|
});
|
|
});
|
|
|
|
describe('FreeBSD version support', () => {
|
|
it('parses FreeBSD major versions', () => {
|
|
expect(parseFreeBSDMajorVersion('15.0-RELEASE')).toBe(15);
|
|
expect(parseFreeBSDMajorVersion('15.0-RELEASE-p8')).toBe(15);
|
|
expect(parseFreeBSDMajorVersion('15.1-RELEASE')).toBe(15);
|
|
expect(parseFreeBSDMajorVersion('14.3-RELEASE')).toBe(14);
|
|
expect(parseFreeBSDMajorVersion('not a version')).toBeNull();
|
|
});
|
|
|
|
it('accepts only the tracked FreeBSD 15 line', () => {
|
|
expect(checkFreeBSDVersionSupport('15.0-RELEASE').ok).toBe(true);
|
|
expect(checkFreeBSDVersionSupport('15.0-RELEASE-p8').ok).toBe(true);
|
|
expect(checkFreeBSDVersionSupport('15.1-RELEASE').ok).toBe(true);
|
|
expect(checkFreeBSDVersionSupport('14.3-RELEASE').ok).toBe(false);
|
|
expect(checkFreeBSDVersionSupport('16.0-RELEASE').ok).toBe(false);
|
|
expect(checkFreeBSDVersionSupport('not a version').ok).toBe(false);
|
|
});
|
|
});
|
|
|
|
// --- getServiceManager ---
|
|
|
|
describe('getServiceManager', () => {
|
|
it('returns a valid service manager', () => {
|
|
const result = getServiceManager();
|
|
expect(['freebsd-rc', 'none']).toContain(result);
|
|
});
|
|
|
|
it('matches the detected platform', () => {
|
|
const platform = getPlatform();
|
|
const result = getServiceManager();
|
|
if (platform === 'freebsd') {
|
|
expect(result).toBe('freebsd-rc');
|
|
} else {
|
|
expect(result).toBe('none');
|
|
}
|
|
});
|
|
});
|
|
|
|
// --- commandExists ---
|
|
|
|
describe('commandExists', () => {
|
|
it('returns true for node', () => {
|
|
expect(commandExists('node')).toBe(true);
|
|
});
|
|
|
|
it('returns false for nonexistent command', () => {
|
|
expect(commandExists('this_command_does_not_exist_xyz_123')).toBe(false);
|
|
});
|
|
});
|
|
|
|
// --- getNodeVersion ---
|
|
|
|
describe('getNodeVersion', () => {
|
|
it('returns a version string', () => {
|
|
const version = getNodeVersion();
|
|
expect(version).not.toBeNull();
|
|
expect(version).toMatch(/^\d+\.\d+\.\d+/);
|
|
});
|
|
});
|
|
|
|
// --- getNodeMajorVersion ---
|
|
|
|
describe('getNodeMajorVersion', () => {
|
|
it('returns at least 20', () => {
|
|
const major = getNodeMajorVersion();
|
|
expect(major).not.toBeNull();
|
|
expect(major!).toBeGreaterThanOrEqual(20);
|
|
});
|
|
});
|
|
|
|
// --- hasBrowser ---
|
|
|
|
describe('hasBrowser', () => {
|
|
it('returns a boolean', () => {
|
|
expect(typeof hasBrowser()).toBe('boolean');
|
|
});
|
|
});
|