Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
zhixzhan committed Dec 17, 2020
1 parent c33295c commit 1565649
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const lgFiles = [
content: `\r\n# Hello\r\n-hi`,
templates: [{ name: 'Hello', body: '-hi', parameters: [] }],
diagnostics: [],
imports: [],
allTemplates: [{ name: 'Hello', body: '-hi', parameters: [] }],
},
] as LgFile[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { LgFile } from '@bfc/shared';
import { lgUtil } from '@bfc/indexers';

import { getBaseName } from '../../../utils/fileUtil';
import { getLanguageFileImports } from '../dialogImports';

Expand Down Expand Up @@ -38,7 +39,14 @@ const files = [

describe('dialogImports selectors', () => {
it('should follow all imports and list all unique imports', () => {
const getFile = (id) => files.find((f) => getBaseName(f.id) === id) as LgFile;
const getFile = (id) => {
const file = files.find((f) => getBaseName(f.id) === id);
if (file) {
return lgUtil.parse(file.id, file.content, []);
} else {
throw new Error(`file ${id} not found`);
}
};

const fileImports = getLanguageFileImports('name1', getFile);
expect(fileImports).toEqual([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const getLanguageFileImports = <T extends LgFile | LuFile | QnAFile>(
return {
displayName: item.description,
importPath: item.path,
id: item.id,
id: getBaseName(item.id),
};
});

Expand Down
1 change: 1 addition & 0 deletions Composer/packages/lib/indexers/src/utils/lgUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import isEmpty from 'lodash/isEmpty';
import { SourceRange } from 'botbuilder-lg/lib/sourceRange';

import { lgIndexer } from '../lgIndexer';

import { getFileName } from './help';

// NOTE: LGDiagnostic is defined in PascalCase which should be corrected
Expand Down

0 comments on commit 1565649

Please sign in to comment.