2018-09-15 20:23:05 +00:00
|
|
|
import { expect, tap } from '@pushrocks/tapbundle';
|
|
|
|
import { Qenv } from '@pushrocks/qenv';
|
2017-09-17 12:53:00 +00:00
|
|
|
|
2018-09-15 20:23:05 +00:00
|
|
|
let testQenv = new Qenv(process.cwd(), process.cwd() + '/.nogit');
|
2017-09-17 12:53:00 +00:00
|
|
|
|
2018-09-15 20:23:05 +00:00
|
|
|
import * as slackme from '../ts/index';
|
2017-09-14 05:20:26 +00:00
|
|
|
|
2018-09-15 20:23:05 +00:00
|
|
|
let testSlackme: slackme.Slackme;
|
|
|
|
let testSlackMessage: slackme.SlackMessage;
|
2017-09-17 12:53:00 +00:00
|
|
|
|
|
|
|
tap.test('should create a valid slackme instance', async () => {
|
2018-09-15 20:23:05 +00:00
|
|
|
testSlackme = new slackme.Slackme(process.env.SLACK_TOKEN);
|
|
|
|
});
|
2017-09-17 12:53:00 +00:00
|
|
|
|
|
|
|
tap.test('should send a message to Slack', async () => {
|
2018-09-15 20:23:05 +00:00
|
|
|
testSlackMessage = new slackme.SlackMessage(
|
|
|
|
{
|
|
|
|
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() / 1000
|
|
|
|
},
|
|
|
|
testSlackme
|
|
|
|
);
|
|
|
|
testSlackme.sendMessage(testSlackMessage.messageOptions, 'random');
|
|
|
|
testSlackMessage.sendToRoom('random');
|
|
|
|
});
|
2018-01-10 20:45:25 +00:00
|
|
|
|
2018-09-15 20:23:05 +00:00
|
|
|
tap.start();
|