Skip to content

Commit 180e13f

Browse files
committed
test: fix and update tests
1 parent 9001695 commit 180e13f

File tree

7 files changed

+70
-3
lines changed

7 files changed

+70
-3
lines changed

package-lock.json

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"husky": "^7.0.2",
105105
"jest": "^27.1.0",
106106
"lint-staged": "^11.1.2",
107+
"memfs": "^3.2.3",
107108
"ts-jest": "^27.0.5",
108109
"typescript": "^4.4.2"
109110
},

src/__tests__/file-structure.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { fs, vol } from 'memfs';
2+
3+
import { getFileStructure } from '../utils/file-structure';
4+
5+
jest.mock('fs');
6+
jest.mock('fs/promises', () => fs.promises);
7+
8+
describe('test file-structure', () => {
9+
beforeEach(() => {
10+
vol.reset();
11+
});
12+
13+
test('get structured file array', async () => {
14+
vol.fromJSON(
15+
{
16+
'file1.js': '',
17+
'file2.ts': '',
18+
'lib/file3.vue': '',
19+
'lib/index.js': ''
20+
},
21+
'./src'
22+
);
23+
24+
expect(await getFileStructure('./src', [])).toEqual([
25+
{ ext: '.js', folder: 'src/', isDir: false, name: 'file1', path: 'src/file1.js' },
26+
{ ext: '.ts', folder: 'src/', isDir: false, name: 'file2', path: 'src/file2.ts' },
27+
{ ext: '.vue', folder: 'src/lib/', isDir: false, name: 'file3', path: 'src/lib/file3.vue' },
28+
{ ext: '.js', folder: 'src/lib/index', isDir: false, name: '_index', path: 'src/lib/index.js' },
29+
{ isDir: true, name: 'lib', path: 'src/lib' }
30+
]);
31+
});
32+
});

src/__tests__/sidebar.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import vueSidebar from '../helpers/vue-sidebar';
1+
import vueSidebar from '../utils/vue-sidebar';
22

33
describe('test sidebar', () => {
44
test('vueSidebar should return valid vue config', () => {

src/__tests__/utils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { checkExtension, getExtension, getFilename, asyncForEach } from '../helpers/utils';
1+
import { checkExtension, getExtension, getFilename, asyncForEach } from '../utils';
22

33
describe('test utils', () => {
44
test('getExtension should return true', () => {

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import mkdirp from 'mkdirp';
77
import path from 'path';
88

99
import { parseFile, parseVueFile } from './parser';
10+
import { checkExtension, getExtension, getFilename, asyncForEach } from './utils';
1011
import parseVuepressComment from './utils/comment-parser';
1112
import { getFileStructure } from './utils/file-structure';
12-
import { checkExtension, getExtension, getFilename, asyncForEach } from './utils/utils';
1313
import vueSidebar from './utils/vue-sidebar';
1414

1515
const fileTree: any[] = [];
File renamed without changes.

0 commit comments

Comments
 (0)