WXL
3 天以前 9bce51f651aad297ef9eb6df832bfdaf1de05d84
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
import path from 'path';
import fs from 'fs';
import { initCommand } from '@/init-command';
 
const configFile = `
module.exports = {
  vueFilesPath: './', // The Vue.js file(s) you want to extract i18n strings from. It can be a path to a folder or to a file. It accepts glob patterns. (ex. *, ?, (pattern|pattern|pattern)
  languageFilesPath: './', // The language file(s) you want to compare your Vue.js file(s) to. It can be a path to a folder or to a file. It accepts glob patterns (ex. *, ?, (pattern|pattern|pattern)
  options: {
    output: false, // false | string => Use if you want to create a json file out of your report. (ex. output.json)
    add: false, // false | true => Use if you want to add missing keys into your json language files.
    dynamic: false, // false | 'ignore' | 'report' => 'ignore' if you want to ignore dynamic keys false-positive. 'report' to get dynamic keys report.
  }
};
`;
 
describe('file: init-command/index', () => {
  describe('function: initCommand', () => {
    let fsWriteFileSync: jest.SpyInstance<unknown>;
 
    beforeEach(() => {
      fsWriteFileSync = jest.spyOn(fs, 'writeFileSync');
      fsWriteFileSync.mockImplementation(() => jest.fn());
    });
 
  it('Log report to console', () => {
      initCommand();
      expect(fsWriteFileSync).toHaveBeenCalledTimes(1);
      expect(fsWriteFileSync).toHaveBeenCalledWith('vue-i18n-extract.config.js', configFile);
    });
  });
});