Skip to content

Commit a3157bf

Browse files
authored
Merge pull request #324 from billba/master
Shell tests
2 parents 4fd8d96 + 7e67886 commit a3157bf

File tree

4 files changed

+50
-4
lines changed

4 files changed

+50
-4
lines changed

src/Chat.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class Chat extends React.Component<ChatProps, {}> {
5454
this.store.dispatch<FormatAction>({ type: 'Set_Format_Options', options: props.formatOptions });
5555

5656
if (props.sendTyping)
57-
this.store.dispatch<ShellAction>({ type: 'Set_Send_Typing' });
57+
this.store.dispatch<ShellAction>({ type: 'Set_Send_Typing', sendTyping: props.sendTyping });
5858
}
5959

6060
private handleIncomingActivity(activity: Activity) {

src/Store.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export type ShellAction = {
1616
type: 'Update_Input',
1717
input: string
1818
} | {
19-
type: 'Set_Send_Typing'
19+
type: 'Set_Send_Typing',
20+
sendTyping: boolean
2021
} | {
2122
type: 'Send_Message',
2223
activity: Activity
@@ -45,7 +46,7 @@ export const shell: Reducer<ShellState> = (
4546
case 'Set_Send_Typing':
4647
return {
4748
... state,
48-
sendTyping: true
49+
sendTyping: action.sendTyping
4950
};
5051

5152
default:

test/history.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const chai = require('chai');
44
const expect = chai.expect;
5-
const history = require('../built/Store.js').history;
5+
const { history } = require('../built/Store.js');
66

77
chai.use(require('chai-subset'));
88

test/shell.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"use strict";
2+
3+
const chai = require('chai');
4+
const expect = chai.expect;
5+
const { shell } = require('../built/Store.js');
6+
7+
chai.use(require('chai-subset'));
8+
9+
describe("shell", () => {
10+
it("should start with an empty input", () => {
11+
expect(shell(undefined, { type: undefined })).to.containSubset({
12+
input: ''
13+
});
14+
});
15+
it("should update when it's intitially updated", () => {
16+
expect(shell(undefined, { type: 'Update_Input', input: 'foo' })).to.containSubset({
17+
input: 'foo'
18+
});
19+
});
20+
it("should update when it's subsequently updated", () => {
21+
expect(shell({ input: 'foo' }, { type: 'Update_Input', input: 'bar' })).to.containSubset({
22+
input: 'bar'
23+
});
24+
});
25+
it("should clear when a message is sent", () => {
26+
expect(shell({ input: 'foo' }, { type: 'Send_Message' })).to.containSubset({
27+
input: ''
28+
});
29+
});
30+
it("should default to not sending typing", () => {
31+
expect(shell(undefined, { type: undefined })).to.containSubset({
32+
sendTyping: false
33+
});
34+
});
35+
it("should update sendTyping to true", () => {
36+
expect(shell(undefined, { type: 'Set_Send_Typing', sendTyping: true })).to.containSubset({
37+
sendTyping: true
38+
});
39+
});
40+
it("should update sendTyping to false", () => {
41+
expect(shell(undefined, { type: 'Set_Send_Typing', sendTyping: false })).to.containSubset({
42+
sendTyping: false
43+
});
44+
});
45+
});

0 commit comments

Comments
 (0)