forked from microsoft/BotFramework-WebChat
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
163 additions
and
37 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
3 changes: 0 additions & 3 deletions
3
__tests__/types/__typescript__/pass/additional-style-options-in-full.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
__tests__/types/__typescript__/pass/import-component-send-text-box.tsx
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
__tests__/types/__typescript__/pass/import-create-direct-line.tsx
This file was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
.../create-direct-line-invalid-bot-agent.tsx → .../create-direct-line-invalid-bot-agent.tsx
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { createDirectLine } from '../../../../packages/bundle'; | ||
import { createDirectLine } from '../../../../lib/index'; | ||
|
||
// "botAgent" is a forbidden option. | ||
createDirectLine({ botAgent: '123' }); |
2 changes: 1 addition & 1 deletion
2
...nce/create-direct-line-invalid-option.tsx → ...nce/create-direct-line-invalid-option.tsx
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { createDirectLine } from '../../../../packages/bundle'; | ||
import { createDirectLine } from '../../../../lib/index'; | ||
|
||
// Object literal may only specify known properties, and 'invalid' does not exist in type 'Omit<CreateDirectLineOptions, "botAgent">'. | ||
createDirectLine({ invalid: true }); |
4 changes: 3 additions & 1 deletion
4
...ipt__/fail-once/invalid-prop-type-dir.tsx → ...ipt__/fail-once/invalid-prop-type-dir.tsx
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import ReactWebChat from '../../../../packages/bundle'; | ||
import React from 'react'; | ||
|
||
import ReactWebChat from '../../../../lib/index'; | ||
|
||
// "dir" must be a string of "ltr' | 'rtl' | 'auto'. | ||
<ReactWebChat dir={123} directLine={undefined} />; |
2 changes: 1 addition & 1 deletion
2
...ons-suggested-actions-stacked-overflow.ts → ...ons-suggested-actions-stacked-overflow.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { createStyleSet } from '../../../../packages/bundle'; | ||
import { createStyleSet } from '../../../../lib/index'; | ||
|
||
// Related to #4081. | ||
createStyleSet({ suggestedActionsStackedOverflow: 'string' }); |
2 changes: 1 addition & 1 deletion
2
...ce/invalid-type-for-use-style-options.tsx → ...ce/invalid-type-for-use-style-options.tsx
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
8 changes: 8 additions & 0 deletions
8
...le/__tests__/types/__typescript__/fail-once/no-children-for-react-web-chat-in-minimal.tsx
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,8 @@ | ||
import React from 'react'; | ||
|
||
import ReactWebChat from '../../../../lib/index-minimal'; | ||
|
||
// <ReactWebChat> should not contains any children. | ||
<ReactWebChat directLine={undefined}> | ||
<div>Hello, World</div> | ||
</ReactWebChat>; |
4 changes: 3 additions & 1 deletion
4
...hildren-for-react-web-chat-in-minimal.tsx → ...ce/no-children-for-react-web-chat.tmp.tsx
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
4 changes: 3 additions & 1 deletion
4
...l-once/no-children-for-react-web-chat.tsx → ...l-once/no-children-for-react-web-chat.tsx
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
2 changes: 1 addition & 1 deletion
2
...dle-style-options-in-minimal-for-hooks.ts → ...dle-style-options-in-minimal-for-hooks.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
2 changes: 1 addition & 1 deletion
2
...o-full-bundle-style-options-in-minimal.ts → ...o-full-bundle-style-options-in-minimal.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { createStyleSet } from '../../../../packages/bundle/lib/index-minimal'; | ||
import { createStyleSet } from '../../../../lib/index-minimal'; | ||
|
||
// "cardEmphasisBackgroundColor" is a style options only available in full bundle. | ||
createStyleSet({ cardEmphasisBackgroundColor: 'orange' }); |
3 changes: 3 additions & 0 deletions
3
packages/bundle/__tests__/types/__typescript__/pass/additional-style-options-in-full.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,3 @@ | ||
import { createStyleSet } from '../../../../lib/index'; | ||
|
||
createStyleSet({ cardEmphasisBackgroundColor: 'orange' }); |
3 changes: 2 additions & 1 deletion
3
...escript__/pass/composition-with-store.tsx → ...escript__/pass/composition-with-store.tsx
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
5 changes: 5 additions & 0 deletions
5
packages/bundle/__tests__/types/__typescript__/pass/correct-type-dir.tsx
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,5 @@ | ||
import React from 'react'; | ||
|
||
import ReactWebChat from '../../../../lib/index'; | ||
|
||
<ReactWebChat dir="ltr" directLine={undefined} />; |
7 changes: 7 additions & 0 deletions
7
packages/bundle/__tests__/types/__typescript__/pass/import-component-send-text-box.tsx
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,7 @@ | ||
import React from 'react'; | ||
|
||
import { Components } from '../../../../lib/index'; | ||
|
||
const { SendTextBox } = Components; | ||
|
||
<SendTextBox />; |
3 changes: 3 additions & 0 deletions
3
packages/bundle/__tests__/types/__typescript__/pass/import-create-direct-line.tsx
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,3 @@ | ||
import { createDirectLine } from '../../../../lib/index'; | ||
|
||
createDirectLine({ token: 'faketoken' }); |
3 changes: 2 additions & 1 deletion
3
...ipt__/pass/render-with-minimal-bundle.tsx → ...ipt__/pass/render-with-minimal-bundle.tsx
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
3 changes: 2 additions & 1 deletion
3
...__typescript__/pass/render-with-store.tsx → ...__typescript__/pass/render-with-store.tsx
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
3 changes: 2 additions & 1 deletion
3
...ript__/pass/render-with-style-options.tsx → ...ript__/pass/render-with-style-options.tsx
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
3 changes: 2 additions & 1 deletion
3
...pescript__/pass/render-with-style-set.tsx → ...pescript__/pass/render-with-style-set.tsx
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
3 changes: 2 additions & 1 deletion
3
...ts__/types/__typescript__/pass/render.tsx → ...ts__/types/__typescript__/pass/render.tsx
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
2 changes: 1 addition & 1 deletion
2
...ass/use-style-options-with-full-bundle.ts → ...ass/use-style-options-with-full-bundle.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
2 changes: 1 addition & 1 deletion
2
...ons-suggested-actions-stacked-overflow.ts → ...ons-suggested-actions-stacked-overflow.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
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...t__/pass/direct-line-activity-from-bot.ts → ...t__/pass/direct-line-activity-from-bot.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
2 changes: 1 addition & 1 deletion
2
...ct-line-activity-from-user-send-failed.ts → ...ct-line-activity-from-user-send-failed.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
2 changes: 1 addition & 1 deletion
2
...direct-line-activity-from-user-sending.ts → ...direct-line-activity-from-user-sending.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
2 changes: 1 addition & 1 deletion
2
...ss/direct-line-activity-from-user-sent.ts → ...ss/direct-line-activity-from-user-sent.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
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,5 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true | ||
} | ||
} |
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,96 @@ | ||
const { join, relative } = require('path'); | ||
const { readdir } = require('fs').promises; | ||
|
||
const ts = require('typescript'); | ||
|
||
function compile(...filenames) { | ||
const program = ts.createProgram(filenames, { | ||
allowSyntheticDefaultImports: true, | ||
jsx: 'react', | ||
noEmit: true, | ||
skipLibCheck: true, | ||
strict: true | ||
}); | ||
|
||
const emitResult = program.emit(); | ||
const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); | ||
const errors = []; | ||
|
||
allDiagnostics.forEach(diagnostic => { | ||
if (diagnostic.file) { | ||
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); | ||
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); | ||
|
||
errors.push(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); | ||
} else { | ||
errors.push(ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n')); | ||
} | ||
}); | ||
|
||
return errors; | ||
} | ||
|
||
describe('compiling TypeScript files', () => { | ||
describe('in /pass/ folder', () => { | ||
let results; | ||
|
||
beforeEach(async () => { | ||
const path = join(__dirname, '__typescript__/pass/'); | ||
let files = []; | ||
|
||
try { | ||
files = await readdir(path); | ||
} catch (error) { | ||
if (error.code !== 'ENOENT') { | ||
throw error; | ||
} | ||
} | ||
|
||
results = {}; | ||
|
||
files.forEach(file => { | ||
const fullPath = join(path, file); | ||
|
||
results[relative(path, fullPath)] = { errors: compile(fullPath) }; | ||
}); | ||
}); | ||
|
||
test('should pass', () => { | ||
for (const filename of Object.keys(results)) { | ||
expect(results).toHaveProperty([filename, 'errors'], []); | ||
expect(results).toHaveProperty([filename, 'errors', 'length'], 0); | ||
} | ||
}); | ||
}); | ||
|
||
describe('in /fail-once/ folder', () => { | ||
let results; | ||
|
||
beforeEach(async () => { | ||
const path = join(__dirname, '__typescript__/fail-once/'); | ||
let files = []; | ||
|
||
try { | ||
files = await readdir(path); | ||
} catch (error) { | ||
if (error.code !== 'ENOENT') { | ||
throw error; | ||
} | ||
} | ||
|
||
results = {}; | ||
|
||
files.forEach(file => { | ||
const fullPath = join(path, file); | ||
|
||
results[relative(path, fullPath)] = { errors: compile(fullPath) }; | ||
}); | ||
}); | ||
|
||
test('should fail only once', () => { | ||
for (const filename of Object.keys(results)) { | ||
expect(results).toHaveProperty([filename, 'errors', 'length'], 1); | ||
} | ||
}); | ||
}); | ||
}); |