Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

util.test.ts 1013 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  1. import { removePrefix } from '../../src/redteam/util';
  2. describe('removePrefix', () => {
  3. it('should remove a simple prefix', () => {
  4. expect(removePrefix('Prompt: Hello world', 'Prompt')).toBe('Hello world');
  5. });
  6. it('should be case insensitive', () => {
  7. expect(removePrefix('PROMPT: Hello world', 'prompt')).toBe('Hello world');
  8. });
  9. it('should remove asterisks from the prefix', () => {
  10. expect(removePrefix('**Prompt:** Hello world', 'Prompt')).toBe('Hello world');
  11. });
  12. it('should handle multiple asterisks', () => {
  13. expect(removePrefix('***Prompt:*** Hello world', 'Prompt')).toBe('Hello world');
  14. });
  15. it('should return the same string if prefix is not found', () => {
  16. expect(removePrefix('Hello world', 'Prefix')).toBe('Hello world');
  17. });
  18. it('should handle empty strings', () => {
  19. expect(removePrefix('', 'Prefix')).toBe('');
  20. });
  21. it('should handle prefix that is the entire string', () => {
  22. expect(removePrefix('Prompt:', 'Prompt')).toBe('');
  23. });
  24. });
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...