-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* lint to form type * fix some bug * update the focused function * add some unit test
- Loading branch information
1 parent
a5f8a7c
commit 21d1b7f
Showing
12 changed files
with
129 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Composer/packages/lib/shared/__tests__/convertUtils/parsePathToFocused.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License | ||
|
||
import { parsePathToFocused } from '../../src'; | ||
|
||
describe('parsePathToFocused', () => { | ||
it('should return focusedPath', () => { | ||
expect(parsePathToFocused('')).toBe(''); | ||
expect(parsePathToFocused('main.trigers[0].actions[0]')).toBe('trigers[0].actions[0]'); | ||
expect(parsePathToFocused('main.trigers[0].actions[0].actions[1]')).toBe('trigers[0].actions[0].actions[1]'); | ||
expect(parsePathToFocused('main.trigers[0].actions[0].elseActions[1]')).toBe( | ||
'trigers[0].actions[0].elseActions[1]' | ||
); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
Composer/packages/lib/shared/__tests__/convertUtils/parsePathToSelected.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License | ||
|
||
import { parsePathToSelected } from '../../src'; | ||
|
||
describe('parsePathToSelected', () => { | ||
it('should return selected path', () => { | ||
expect(parsePathToSelected('')).toBe(''); | ||
expect(parsePathToSelected('main.triggers[0].actions[0]')).toBe('triggers[0]'); | ||
expect(parsePathToSelected('main')).toBe(''); | ||
expect(parsePathToSelected('main.triggers[0]')).toBe('triggers[0]'); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
Composer/packages/lib/shared/__tests__/convertUtils/parseTypeToFragment.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License | ||
|
||
import { parseTypeToFragment, PromptTab } from './../../src'; | ||
|
||
describe('parseTypeToFragment', () => { | ||
it('should return corrent tab name', () => { | ||
expect(parseTypeToFragment('Microsoft.TextInput', 'unrecognizedPrompt')).toBe(PromptTab.OTHER); | ||
expect(parseTypeToFragment('Microsoft.TextInput', 'property')).toBe(PromptTab.USER_INPUT); | ||
expect(parseTypeToFragment('Microsoft.TextInput', 'prompt')).toBe(PromptTab.BOT_ASKS); | ||
expect(parseTypeToFragment('Microsoft.NumberInput', 'property')).toBe(PromptTab.USER_INPUT); | ||
expect(parseTypeToFragment('Microsoft.LuisRecognizer', 'property')).toBe(''); | ||
expect(parseTypeToFragment('test', 'items')).toBe(''); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
export * from './parsePathToFocused'; | ||
export * from './parsePathToSelected'; | ||
export * from './parseTypeToFragment'; |
14 changes: 14 additions & 0 deletions
14
Composer/packages/lib/shared/src/convertUtils/parsePathToFocused.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
export function parsePathToFocused(path: string): string { | ||
//path is like main.trigers[0].actions[0] | ||
|
||
const list = path.split('.'); | ||
|
||
if (list.length > 2) { | ||
list.shift(); | ||
return list.join('.'); | ||
} | ||
return ''; | ||
} |
13 changes: 13 additions & 0 deletions
13
Composer/packages/lib/shared/src/convertUtils/parsePathToSelected.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
export function parsePathToSelected(path: string): string { | ||
//path is like main.trigers[0].actions[0] | ||
|
||
const triggerPattern = /triggers\[(\d+)\]/g; | ||
const matchTriggers = triggerPattern.exec(path); | ||
|
||
const trigger = matchTriggers ? `triggers[${+matchTriggers[1]}]` : ''; | ||
|
||
return trigger; | ||
} |
16 changes: 16 additions & 0 deletions
16
Composer/packages/lib/shared/src/convertUtils/parseTypeToFragment.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { dialogGroups, DialogGroup } from '../viewUtils'; | ||
import { PromptTab } from '../promptTabs'; | ||
|
||
export function parseTypeToFragment(type: string, property: string): string { | ||
const inputTypes = dialogGroups[DialogGroup.INPUT].types; | ||
const index = inputTypes.findIndex(t => t === type); | ||
if (index >= 0) { | ||
if (property === 'property') return PromptTab.USER_INPUT; | ||
if (property === 'prompt') return PromptTab.BOT_ASKS; | ||
return PromptTab.OTHER; | ||
} | ||
return ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters