Skip to content

Commit

Permalink
Add unit tests for the getSystemPrompt function in prompts.test.ts.
Browse files Browse the repository at this point in the history
  • Loading branch information
gru-agent[bot] authored Jan 22, 2025
1 parent 2ae897a commit 10a8238
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/lib/common/prompts/prompts.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { describe, expect, it } from 'vitest';
import { getSystemPrompt } from './prompts';
import { MODIFICATIONS_TAG_NAME, WORK_DIR } from '~/utils/constants';
import { allowedHTMLElements } from '~/utils/markdown';

describe('getSystemPrompt', () => {
it('should return system prompt with default work dir', () => {
const result = getSystemPrompt();
expect(result).toContain(`The current working directory is \`${WORK_DIR}\`.`);
expect(result).toContain(`<${MODIFICATIONS_TAG_NAME}>`);
expect(result).toContain(`</${MODIFICATIONS_TAG_NAME}>`);
expect(result).toContain(allowedHTMLElements.map((tag) => `<${tag}>`).join(', '));
});

it('should use provided working directory', () => {
const customDir = '/custom/dir';
const result = getSystemPrompt(customDir);
expect(result).toContain(`The current working directory is \`${customDir}\`.`);
});
});

0 comments on commit 10a8238

Please sign in to comment.