Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…h-themer into vNext
  • Loading branch information
michaeljolley committed Jun 26, 2019
2 parents cfbd768 + bc69db9 commit 84af4e7
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- New `!theme repo` will now send a message to chat with information about the extensions GitHub repo.
- Added the `!theme help` command to explain to chat how to use the extensions commands

---

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

#### Send info about this GitHub repo to chat

This will send a message to Twitch chat letting everyone know where to access the source for this extension.

```
!theme repo
```

#### 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
31 changes: 29 additions & 2 deletions src/commands/Themer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export class Themer {
}
}


public async handleChatConnectionChanged(signedIn: boolean) {
if (signedIn) {
if (keytar) {
Expand Down Expand Up @@ -165,9 +164,15 @@ export class Themer {
case 'random':
await this.randomTheme(twitchUser);
break;
case 'help':
await this.help();
break;
case 'refresh':
await this.refreshThemes(twitchUser);
break;
case 'repo':
await this.repo();
break;
case 'ban':
if (username !== undefined) {
await this.ban(twitchUser, username);
Expand Down Expand Up @@ -427,7 +432,8 @@ export class Themer {
}
} else {
this.sendMessageEventEmitter.fire(
`${twitchDisplayName}, ${themeName} is not a valid theme name or isn't installed. You can use !theme to get a list of available themes.`
`${twitchDisplayName}, ${themeName} is not a valid theme name or \
isn't installed. You can use !theme to get a list of available themes.`
);
}
}
Expand All @@ -442,6 +448,27 @@ export class Themer {
this.sendMessageEventEmitter.fire(`The current theme is ${currentTheme}`);
}

/**
* Announces to chat info about the extensions GitHub repository
*/
private async repo() {
const repoMessage = 'You can find the source code for this VS \
Code extension at https://github.com/MichaelJolley/vscode-twitch-themer. \
Feel free to Fork & contribute.';
this.sendMessageEventEmitter.fire(repoMessage);
}

/**
* 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
53 changes: 53 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 All @@ -119,6 +147,31 @@ suite('Themer Tests', function() {
});
});

test(`Themer should return info about the GitHub repo`, function(done) {
let sentMessage: string = '';
const sendMessageStub = sinon
.stub(fakeChatClient, 'sendMessage')
.callsFake((message: string) => {
sentMessage = message;
});
fakeThemer.onSendMesssage(sendMessageStub);

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

fakeThemer.handleCommands(chatMessage).then(() => {
try {
sendMessageStub.calledOnce.should.be.true;
sentMessage.should.equal('You can find the source code for this VS \
Code extension at https://github.com/MichaelJolley/vscode-twitch-themer. \
Feel free to Fork & contribute.');
done();
} catch (error) {
done(error);
}
});
});

test('Themer should reset theme to original theme when requested', function(done) {
fakeWorkspaceConfiguration.update('workbench.colorTheme', testTheme);

Expand Down

0 comments on commit 84af4e7

Please sign in to comment.