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

validateAssertions.test.ts 1.5 KB

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  1. import { validateAssertions, AssertValidationError } from '../../src/assertions/validateAssertions';
  2. import type { TestCase } from '../../src/types';
  3. describe('validateAssertions', () => {
  4. const test: TestCase = {
  5. description: 'The test case',
  6. };
  7. describe('asssert-set', () => {
  8. function testCaseWithAssertSet(assertSet: object) {
  9. return {
  10. ...test,
  11. assert: [{ type: 'assert-set', ...assertSet } as any],
  12. };
  13. }
  14. it('does not fail on valid assert-set', () => {
  15. const test = testCaseWithAssertSet({
  16. assert: [
  17. {
  18. type: 'equals',
  19. value: 'Expected output',
  20. },
  21. ],
  22. });
  23. expect(() => validateAssertions([test])).not.toThrow();
  24. });
  25. it('has assert', () => {
  26. const test = testCaseWithAssertSet({});
  27. expect(() => validateAssertions([test])).toThrow(
  28. new AssertValidationError('assert-set must have an `assert` property', test),
  29. );
  30. });
  31. it('has assert as an array', () => {
  32. const test = testCaseWithAssertSet({ assert: {} });
  33. expect(() => validateAssertions([test])).toThrow(
  34. new AssertValidationError('assert-set `assert` must be an array of assertions', test),
  35. );
  36. });
  37. it('does not have child assert-sets', () => {
  38. const test = testCaseWithAssertSet({ assert: [{ type: 'assert-set' }] });
  39. expect(() => validateAssertions([test])).toThrow(
  40. new AssertValidationError('assert-set must not have child assert-sets', test),
  41. );
  42. });
  43. });
  44. });
Tip!

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

Comments

Loading...