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

leetspeak.test.ts 976 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
  1. import { addLeetspeak } from '../../../src/redteam/strategies/leetspeak';
  2. import type { TestCase } from '../../../src/types';
  3. describe('addLeetspeak', () => {
  4. const mockTestCases: TestCase[] = [
  5. {
  6. vars: { query: 'Hello, world!' },
  7. assert: [{ type: 'equals', value: 'Expected output', metric: 'Harmful' }],
  8. },
  9. {
  10. vars: { userInput: 'Test input' },
  11. assert: [{ type: 'contains', value: 'test', metric: 'DebugAccess' }],
  12. },
  13. ];
  14. it('should convert the inject variable to leetspeak', () => {
  15. const result = addLeetspeak(mockTestCases, 'query');
  16. expect(result[0].vars?.query).toBe('H3110, w0r1d!');
  17. });
  18. it('should handle uppercase and lowercase letters', () => {
  19. const testCase: TestCase = {
  20. vars: { text: 'HELLO hello' },
  21. assert: [{ type: 'equals', value: 'Test', metric: 'Test' }],
  22. };
  23. const result = addLeetspeak([testCase], 'text');
  24. expect(result[0].vars?.text).toBe('H3110 h3110');
  25. });
  26. });
Tip!

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

Comments

Loading...