Skip to content

Commit

Permalink
Add more types checks -- NOT PASSING
Browse files Browse the repository at this point in the history
  • Loading branch information
corinagum committed May 24, 2021
1 parent 4598fa6 commit ab870d9
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 1 deletion.
7 changes: 7 additions & 0 deletions __tests__/types/__typescript__/componentSendTextBox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Components } from '../../../packages/bundle/lib/index';

function main() {
const { SendTextBox } = Components;

return <SendTextBox />;
}
5 changes: 5 additions & 0 deletions __tests__/types/__typescript__/dirInComposer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Composer from '../../../packages/component/lib/Composer';

function main() {
return <Composer dir='rtl' />;
}
8 changes: 8 additions & 0 deletions __tests__/types/__typescript__/directLineInComposer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Composer from '../../../packages/component/lib/Composer';
import createDirectLine from '../../../packages/bundle/lib/createDirectLine';

function main() {
const directLine = createDirectLine({ token: 'faketoken'});

return <Composer directLine={directLine} />;
}
8 changes: 8 additions & 0 deletions __tests__/types/__typescript__/directLineObject.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import ReactWebChat from '../../../packages/bundle/lib/index';
import createDirectLine from '../../../packages/bundle/lib/createDirectLine';

function main() {
const directLine = createDirectLine({ token: 'faketoken'});

return <ReactWebChat directLine={directLine} />;
}
8 changes: 8 additions & 0 deletions __tests__/types/__typescript__/storeInComposer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Composer from '../../../packages/component/lib/Composer';
import createStore from '../../../packages/core/lib/createStore';

function main() {
const store = createStore({});

return <Composer store={store} />;
}
8 changes: 8 additions & 0 deletions __tests__/types/__typescript__/storeObject.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import ReactWebChat from '../../../packages/bundle/lib/index';
import createStore from '../../../packages/core/lib/createStore';

function main() {
const store = createStore({});

return <ReactWebChat store={store} />;
}
2 changes: 1 addition & 1 deletion __tests__/types/__typescript__/styleOptionsAccent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ function main() {

createStyleSet(styleOptions);

// Verify: Setting "accent" must should pass.
// Verify: Setting "accent" must pass.
return <ReactWebChat dir="ltr" styleOptions={styleOptions} />;
}
35 changes: 35 additions & 0 deletions __tests__/types/typesCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,29 @@ function compile(...filenames) {
return errors;
};

it('should pass with non-exported component type SendTextBox', () => {
const componentErrors = compile(path.join(__dirname, './__typescript__/componentSendTextBox.tsx'));

expect(componentErrors).toHaveProperty('length', 0);
});

it('should pass with non-exported type directLine', () => {
const directLineErrors = compile(path.join(__dirname, './__typescript__/directLineObject.tsx'));

expect(directLineErrors).toHaveProperty('length', 0);
});

it('should pass with non-exported type directLine in Composer', () => {
const directLineErrors = compile(path.join(__dirname, './__typescript__/directLineInComposer.tsx'));

expect(directLineErrors).toHaveProperty('length', 0);
});

it('should pass dir as string in Composer ', () => {
const dirStringErrors = compile(path.join(__dirname, './__typescript__/dirInComposer.tsx'));

expect(dirStringErrors).toHaveProperty('length', 0);
});

it('should pass dir as string', () => {
const dirStringErrors = compile(path.join(__dirname, './__typescript__/dirString.tsx'));
Expand All @@ -40,6 +63,18 @@ it('should fail on dir as number', () => {
expect(dirNumErrors[0]).toEqual(expect.stringContaining(`Type 'number' is not assignable to type '"ltr" | "rtl" | "auto"'`));
});

it('should pass with non-exported type store', () => {
const storeObjectErrors = compile(path.join(__dirname, './__typescript__/storeObject.tsx'));

expect(storeObjectErrors).toHaveProperty('length', 0);
});

it('should pass with non-exported type store in Composer ', () => {
const storeObjectErrors = compile(path.join(__dirname, './__typescript__/storeInComposer.tsx'));

expect(storeObjectErrors).toHaveProperty('length', 0);
});

it('should fail on accent', () => {
const accentErrors = compile(path.join(__dirname, './__typescript__/styleOptionsAccent.tsx'));

Expand Down

0 comments on commit ab870d9

Please sign in to comment.