Skip to main content
Glama
push-based

Angular Toolkit MCP

by push-based
os-agnostic-paths.unit.test.ts3.82 kB
import { type MockInstance, afterEach, beforeEach, describe, expect, it, vi, } from 'vitest'; import { osAgnosticPath } from './os-agnostic-paths'; describe('osAgnosticPath', () => { const cwdSpy: MockInstance<[], string> = vi.spyOn(process, 'cwd'); it('should forward nullish paths on Linux/macOS and Windows', () => { expect(osAgnosticPath(undefined)).toBeUndefined(); }); describe('Unix-based systems (Linux/macOS)', () => { const unixCwd = '/Users/jerry'; beforeEach(() => { cwdSpy.mockReturnValue(unixCwd); }); afterEach(() => { cwdSpy.mockReset(); }); it('should convert a path within the CWD to an OS-agnostic path on Linux/macOS', () => { expect( osAgnosticPath(`${unixCwd}/.code-pushup/.code-pushup.config.ts`), ).toBe('<CWD>/.code-pushup/.code-pushup.config.ts'); }); it('should return paths outside of CWD on Linux/macOS', () => { expect( osAgnosticPath(`${unixCwd}/../.code-pushup/.code-pushup.config.ts`), ).toBe('../.code-pushup/.code-pushup.config.ts'); }); it('should handle absolute paths correctly on Linux/macOS', () => { expect(osAgnosticPath('/.code-pushup/.code-pushup.config.ts')).toBe( '/.code-pushup/.code-pushup.config.ts', ); }); it('should handle paths with CWD shorthand "." correctly on Linux/macOS', () => { expect(osAgnosticPath('./.code-pushup/.code-pushup.config.ts')).toBe( './.code-pushup/.code-pushup.config.ts', ); }); it('should handle relative paths correctly on Linux/macOS', () => { expect(osAgnosticPath('../../.code-pushup/.code-pushup.config.ts')).toBe( '../../.code-pushup/.code-pushup.config.ts', ); }); it('should handle path segments correctly on Linux/macOS', () => { expect(osAgnosticPath('.code-pushup/.code-pushup.config.ts')).toBe( '.code-pushup/.code-pushup.config.ts', ); }); it('should NOT modify already OS-agnostic paths on Linux/macOS', () => { expect(osAgnosticPath('<CWD>/.code-pushup/.code-pushup.config.ts')).toBe( '<CWD>/.code-pushup/.code-pushup.config.ts', ); }); }); describe('Windows', () => { const windowsCWD = String.raw`D:\\users\\jerry`; beforeEach(() => { cwdSpy.mockReturnValue(windowsCWD); }); afterEach(() => { cwdSpy.mockReset(); }); it('should return paths outside of CWD on Windows', () => { expect( osAgnosticPath( `${windowsCWD}\\..\\.code-pushup\\.code-pushup.config.ts`, ), ).toBe('../.code-pushup/.code-pushup.config.ts'); }); it('should convert a path within the CWD to an OS-agnostic path on Windows', () => { expect( osAgnosticPath(`${windowsCWD}\\.code-pushup\\.code-pushup.config.ts`), ).toBe('<CWD>/.code-pushup/.code-pushup.config.ts'); }); it('should handle absolute paths correctly on Windows', () => { expect( osAgnosticPath(String.raw`\.code-pushup\.code-pushup.config.ts`), ).toBe('/.code-pushup/.code-pushup.config.ts'); }); it('should handle paths with CWD shorthand "." correctly on Windows', () => { expect( osAgnosticPath(String.raw`.\.code-pushup\.code-pushup.config.ts`), ).toBe('./.code-pushup/.code-pushup.config.ts'); }); it('should handle relative paths correctly on Windows', () => { expect( osAgnosticPath(String.raw`..\..\.code-pushup\.code-pushup.config.ts`), ).toBe('../../.code-pushup/.code-pushup.config.ts'); }); it('should handle path segments correctly on Windows', () => { expect( osAgnosticPath(String.raw`.code-pushup\.code-pushup.config.ts`), ).toBe('.code-pushup/.code-pushup.config.ts'); }); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/push-based/angular-toolkit-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server