Skip to content

Commit

Permalink
test: fix and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ph1p committed Sep 1, 2021
1 parent 9001695 commit 180e13f
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 3 deletions.
34 changes: 34 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"husky": "^7.0.2",
"jest": "^27.1.0",
"lint-staged": "^11.1.2",
"memfs": "^3.2.3",
"ts-jest": "^27.0.5",
"typescript": "^4.4.2"
},
Expand Down
32 changes: 32 additions & 0 deletions src/__tests__/file-structure.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { fs, vol } from 'memfs';

import { getFileStructure } from '../utils/file-structure';

jest.mock('fs');
jest.mock('fs/promises', () => fs.promises);

describe('test file-structure', () => {
beforeEach(() => {
vol.reset();
});

test('get structured file array', async () => {
vol.fromJSON(
{
'file1.js': '',
'file2.ts': '',
'lib/file3.vue': '',
'lib/index.js': ''
},
'./src'
);

expect(await getFileStructure('./src', [])).toEqual([
{ ext: '.js', folder: 'src/', isDir: false, name: 'file1', path: 'src/file1.js' },
{ ext: '.ts', folder: 'src/', isDir: false, name: 'file2', path: 'src/file2.ts' },
{ ext: '.vue', folder: 'src/lib/', isDir: false, name: 'file3', path: 'src/lib/file3.vue' },
{ ext: '.js', folder: 'src/lib/index', isDir: false, name: '_index', path: 'src/lib/index.js' },
{ isDir: true, name: 'lib', path: 'src/lib' }
]);
});
});
2 changes: 1 addition & 1 deletion src/__tests__/sidebar.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import vueSidebar from '../helpers/vue-sidebar';
import vueSidebar from '../utils/vue-sidebar';

describe('test sidebar', () => {
test('vueSidebar should return valid vue config', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { checkExtension, getExtension, getFilename, asyncForEach } from '../helpers/utils';
import { checkExtension, getExtension, getFilename, asyncForEach } from '../utils';

describe('test utils', () => {
test('getExtension should return true', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import mkdirp from 'mkdirp';
import path from 'path';

import { parseFile, parseVueFile } from './parser';
import { checkExtension, getExtension, getFilename, asyncForEach } from './utils';
import parseVuepressComment from './utils/comment-parser';
import { getFileStructure } from './utils/file-structure';
import { checkExtension, getExtension, getFilename, asyncForEach } from './utils/utils';
import vueSidebar from './utils/vue-sidebar';

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

0 comments on commit 180e13f

Please sign in to comment.