Skip to content

Commit

Permalink
Merge pull request #91 from MichaelJolley/features/help-command
Browse files Browse the repository at this point in the history
Adding the !theme help message to explain how to use extension to cha…
  • Loading branch information
michaeljolley authored Jun 25, 2019
2 parents b4397fe + 1056d0d commit bb334e5
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Added the `!theme help` command to explain to chat how to use the extensions commands

---

## [1.0.1] - 2019-06-09
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ This will send the currently active theme to Twitch chat.
!theme current
```

#### Explain how to use the extensions commands

This will send a message to Twitch chat explaining the available commands.

```
!theme help
```

#### Set VS Code theme

This command will set the theme of the streamers' VS Code workspace to the theme specified.
Expand Down
14 changes: 14 additions & 0 deletions src/commands/Themer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ export class Themer {
case 'random':
await this.randomTheme(twitchUser);
break;
case 'help':
await this.help();
break;
case 'refresh':
await this.refreshThemes(twitchUser);
break;
Expand Down Expand Up @@ -442,6 +445,17 @@ export class Themer {
this.sendMessageEventEmitter.fire(`The current theme is ${currentTheme}`);
}

/**
* Announces to chat a message with a brief explanation of how to use the commands
*/
private async help() {
const helpMessage: string = `You can change the theme of the stream's VS\
Code by sending '!theme random'. You can also choose a theme\
specifically. Send '!theme' to be whispered a list of available\
themes.`;
this.sendMessageEventEmitter.fire(helpMessage);
}

/**
* Clears the list of recipients so they can request the list of themes again
*/
Expand Down
28 changes: 28 additions & 0 deletions src/test/themer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,34 @@ suite('Themer Tests', function() {
getConfigurationStub.resetHistory();
});

test(`Themer should explain how to use extension to chat`, function(done) {
let sentMessage: string = '';
const sendMessageStub = sinon
.stub(fakeChatClient, 'sendMessage')
.callsFake((message: string) => {
sentMessage = message;
});
fakeThemer.onSendMesssage(sendMessageStub);

const message = 'help';
const chatMessage: IChatMessage = { message, userState: user };

const helpMessage: string = `You can change the theme of the stream's VS\
Code by sending '!theme random'. You can also choose a theme\
specifically. Send '!theme' to be whispered a list of available\
themes.`;

fakeThemer.handleCommands(chatMessage).then(() => {
try {
sendMessageStub.calledOnce.should.be.true;
sentMessage.should.equal(helpMessage);
done();
} catch (error) {
done(error);
}
});
});

test(`Themer should return current theme (${baseTheme})`, function(done) {
let sentMessage: string = '';
const sendMessageStub = sinon
Expand Down

0 comments on commit bb334e5

Please sign in to comment.