aboutsummaryrefslogtreecommitdiff
path: root/test/scripts/apidocs/method.spec.ts
blob: 14c9cfc00ec573ad4b64d35b9a94e02f5329f0b9 (plain)
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
import { describe, expect, it } from 'vitest';
import { processMethodLike } from '../../../scripts/apidocs/processing/method';
import { SignatureTest } from './method.example';
import { loadExampleMethods } from './utils';

const methods = loadExampleMethods();

describe('method', () => {
  it('dummy dependency to rerun the test if the example changes', () => {
    expect(new SignatureTest()).toBeTruthy();
  });

  it('expected and actual methods are equal', () => {
    expect(Object.keys(methods)).toMatchSnapshot();
  });

  it.each(Object.entries(methods))(
    'processMethodLike(%s)',
    (name, signature) => {
      const actual = processMethodLike(name, signature);
      actual.source = {
        filePath: actual.source.filePath,
        line: -1,
        column: -1,
      };

      expect(actual).toMatchSnapshot();
    }
  );
});