This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

vit / test / link.test.js
1.3 kB 40 lines
1// SPDX-License-Identifier: MIT 2// Copyright (c) 2026 sol pbc 3 4import { describe, test, expect, afterEach } from 'bun:test'; 5import { run } from './helpers.js'; 6import { mkdirSync, rmSync, existsSync } from 'node:fs'; 7import { tmpdir } from 'node:os'; 8import { join } from 'node:path'; 9 10describe('vit link', () => { 11 let tmpHome; 12 13 afterEach(() => { 14 if (tmpHome) rmSync(tmpHome, { recursive: true, force: true }); 15 }); 16 17 test('--help shows usage', () => { 18 const result = run('link --help'); 19 expect(result.stdout).toContain('Link'); 20 expect(result.exitCode).toBe(0); 21 }); 22 23 test('creates symlink without error', () => { 24 tmpHome = join(tmpdir(), '.test-link-' + Math.random().toString(36).slice(2)); 25 mkdirSync(tmpHome, { recursive: true }); 26 const result = run('link', undefined, { HOME: tmpHome }); 27 expect(result.exitCode).toBe(0); 28 const linkPath = join(tmpHome, '.local', 'bin', 'vit'); 29 expect(existsSync(linkPath)).toBe(true); 30 }); 31 32 test('is idempotent', () => { 33 tmpHome = join(tmpdir(), '.test-link-' + Math.random().toString(36).slice(2)); 34 mkdirSync(tmpHome, { recursive: true }); 35 const env = { HOME: tmpHome }; 36 run('link', undefined, env); 37 const result = run('link', undefined, env); 38 expect(result.exitCode).toBe(0); 39 }); 40});