2017-09-14 05:20:26 +00:00
|
|
|
import { expect, tap } from 'tapbundle'
|
2017-09-17 12:53:00 +00:00
|
|
|
import { Qenv } from 'qenv'
|
|
|
|
|
|
|
|
let testQenv = new Qenv(process.cwd(), process.cwd() + '/.nogit')
|
|
|
|
|
2017-09-14 05:20:26 +00:00
|
|
|
import * as slackme from '../ts/index'
|
|
|
|
|
2017-09-17 12:53:00 +00:00
|
|
|
let testSlackme: slackme.Slackme
|
2018-01-10 20:45:25 +00:00
|
|
|
let testSlackMessage: slackme.SlackMessage
|
2017-09-17 12:53:00 +00:00
|
|
|
|
|
|
|
tap.test('should create a valid slackme instance', async () => {
|
|
|
|
testSlackme = new slackme.Slackme(process.env.SLACK_TOKEN)
|
|
|
|
})
|
|
|
|
|
|
|
|
tap.test('should send a message to Slack', async () => {
|
2018-01-10 20:45:25 +00:00
|
|
|
testSlackMessage = new slackme.SlackMessage({
|
2017-09-17 13:25:00 +00:00
|
|
|
author_name: 'GitLab CI',
|
|
|
|
author_link: 'https://gitlab.com/',
|
|
|
|
pretext: '*Good News*: Build successfull!',
|
|
|
|
color: '#3cb371',
|
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
title: 'Branch',
|
|
|
|
value: 'Lossless Cloud',
|
|
|
|
short: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Product ID',
|
|
|
|
value: 'pushrocks',
|
|
|
|
short: true
|
|
|
|
}
|
|
|
|
],
|
|
|
|
ts: (new Date()).getTime()
|
2018-01-10 20:45:25 +00:00
|
|
|
}, testSlackme)
|
|
|
|
testSlackme.sendMessage(testSlackMessage.messageOptions, 'random')
|
|
|
|
testSlackMessage.sendToRoom('random')
|
|
|
|
|
2017-09-14 05:20:26 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
tap.start()
|