CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
configHash.test.ts67 linesDownload Raw Back to lsp
1/**2 * @license3 * Copyright 2025 Qwen Team4 * SPDX-License-Identifier: Apache-2.05 */6 7import { describe, expect, it } from 'vitest';8import type { LspServerConfig } from './types.js';9import { lspServerConfigHash } from './configHash.js';10 11const baseConfig: LspServerConfig = {12  name: 'tsserver',13  languages: ['typescript'],14  command: 'typescript-language-server',15  args: ['--stdio'],16  transport: 'stdio',17  env: { B: '2', A: '1' },18  settings: { beta: true, alpha: { z: 1, a: 2 } },19  rootUri: 'file:///workspace',20  workspaceFolder: '/workspace',21  trustRequired: true,22};23 24describe('lspServerConfigHash', () => {25  it('ignores object key order', () => {26    const reordered: LspServerConfig = {27      ...baseConfig,28      env: { A: '1', B: '2' },29      settings: { alpha: { a: 2, z: 1 }, beta: true },30    };31 32    expect(lspServerConfigHash(reordered)).toBe(33      lspServerConfigHash(baseConfig),34    );35  });36 37  it('treats argument order as semantic', () => {38    expect(39      lspServerConfigHash({40        ...baseConfig,41        args: ['--stdio', '--log'],42      }),43    ).not.toBe(44      lspServerConfigHash({45        ...baseConfig,46        args: ['--log', '--stdio'],47      }),48    );49  });50 51  it('changes when runtime config fields change', () => {52    expect(53      lspServerConfigHash({54        ...baseConfig,55        command: 'other-server',56      }),57    ).not.toBe(lspServerConfigHash(baseConfig));58 59    expect(60      lspServerConfigHash({61        ...baseConfig,62        trustRequired: false,63      }),64    ).not.toBe(lspServerConfigHash(baseConfig));65  });66});67 
basant307/AI_Governance_Project · CoolFace