summaryrefslogtreecommitdiff
path: root/spec/frontend/ide/lib/editorconfig/parser_spec.js
blob: c2b4a8e6c49f4f7d7b03483304919a587ed01bed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { getRulesWithTraversal } from '~/ide/lib/editorconfig/parser';
import { exampleConfigs, exampleFiles } from './mock_data';

describe('~/ide/lib/editorconfig/parser', () => {
  const getExampleConfigContent = (path) =>
    Promise.resolve(exampleConfigs.find((x) => x.path === path)?.content);

  describe('getRulesWithTraversal', () => {
    it.each(exampleFiles)(
      'traverses through all editorconfig files in parent directories (until root=true is hit) and finds rules for this file (case %#)',
      ({ path, rules }) => {
        return getRulesWithTraversal(path, getExampleConfigContent).then((result) => {
          expect(result).toEqual(rules);
        });
      },
    );
  });
});