WXL
9 天以前 2895b4ea66e09cb355aeb4e030ca0de297bf8ce3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { parseVueFiles } from '@/report-command/vue-files';
import { expectedFromParsedVueFiles } from '../fixtures/expected-values';
import { vueFiles } from '../fixtures/resolved-sources';
import path from 'path';
 
describe('file: report-command/vue-files', () => {
  describe('function: parseVueFiles', () => {
    it('Parse the file glob into and I18Nvue object', () => {
      const results = parseVueFiles(vueFiles);
      expect(results).toEqual(expectedFromParsedVueFiles);
    });
 
    it('Throws an error if it is not a valid glob', () => {
      const breakingVueFiles = '';
      expect(() => parseVueFiles(breakingVueFiles)).toThrow(`vueFiles isn't a valid glob pattern.`);
    });
 
    it('Throws an error if it does not find any file', () => {
      const breakingVueFiles = path.resolve(__dirname, '../fixtures/vue-files/**/*.txt');
      expect(() => parseVueFiles(breakingVueFiles)).toThrow('vueFiles glob has no files.');
    });
  });
})