forked from slackapi/hubot-slack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request slackapi#122 from paulhammond/remove-formatting
More formatting fixes
- Loading branch information
Showing
2 changed files
with
75 additions
and
9 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
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 |
---|---|---|
|
@@ -14,10 +14,13 @@ beforeEach -> | |
stubs = | ||
# Slack client | ||
channel: | ||
name: 'general' | ||
send: (msg) -> msg | ||
client: | ||
getUserByID: (id) -> | ||
{name: 'name', email_address: '[email protected]'} | ||
getChannelByID: (id) -> | ||
stubs.channel | ||
getChannelGroupOrDMByName: () -> | ||
stubs.channel | ||
# Hubot.Robot instance | ||
|
@@ -50,7 +53,6 @@ describe 'Login', -> | |
slackbot.robot.name.should.equal 'bot' | ||
|
||
describe 'Removing message formatting', -> | ||
|
||
it 'Should do nothing if there are no user links', -> | ||
foo = slackbot.removeFormatting 'foo' | ||
foo.should.equal 'foo' | ||
|
@@ -63,9 +65,45 @@ describe 'Removing message formatting', -> | |
foo = slackbot.removeFormatting 'foo <@U123|label> bar' | ||
foo.should.equal 'foo label bar' | ||
|
||
it 'Should change <#C1234> links to #general', -> | ||
foo = slackbot.removeFormatting 'foo <#C123> bar' | ||
foo.should.equal 'foo #general bar' | ||
|
||
it 'Should change <#C1234|label> links to label', -> | ||
foo = slackbot.removeFormatting 'foo <#C123|label> bar' | ||
foo.should.equal 'foo label bar' | ||
|
||
it 'Should change <!everyone> links to @everyone', -> | ||
foo = slackbot.removeFormatting 'foo <!everyone> bar' | ||
foo.should.equal 'foo @everyone bar' | ||
|
||
it 'Should change <!channel> links to @channel', -> | ||
foo = slackbot.removeFormatting 'foo <!channel> bar' | ||
foo.should.equal 'foo @channel bar' | ||
|
||
it 'Should change <!group> links to @group', -> | ||
foo = slackbot.removeFormatting 'foo <!group> bar' | ||
foo.should.equal 'foo @group bar' | ||
|
||
it 'Should remove formatting around <http> links', -> | ||
foo = slackbot.removeFormatting 'foo <http://www.example.com> bar' | ||
foo.should.equal 'foo http://www.example.com bar' | ||
|
||
it 'Should remove formatting around <https> links', -> | ||
foo = slackbot.removeFormatting 'foo <https://www.example.com> bar' | ||
foo.should.equal 'foo https://www.example.com bar' | ||
|
||
it 'Should remove formatting around <mailto> links', -> | ||
foo = slackbot.removeFormatting 'foo <mailto:[email protected]> bar' | ||
foo.should.equal 'foo mailto:[email protected] bar' | ||
|
||
it 'Should remove formatting around <https> links with a label', -> | ||
foo = slackbot.removeFormatting 'foo <https://www.example.com|label> bar' | ||
foo.should.equal 'foo label https://www.example.com bar' | ||
|
||
it 'Should change multiple links at once', -> | ||
foo = slackbot.removeFormatting 'foo <@U123|label> bar <@U123>' | ||
foo.should.equal 'foo label bar @name' | ||
foo = slackbot.removeFormatting 'foo <@U123|label> bar <#C123> <!channel> <https://www.example.com|label>' | ||
foo.should.equal 'foo label bar #general @channel label https://www.example.com' | ||
|
||
describe 'Send Messages', -> | ||
it 'Should send multiple messages', -> | ||
|