Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

coverbadge

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coverbadge - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

2

package.json
{
"name": "coverbadge",
"version": "0.4.1",
"version": "0.5.0",
"description": "Create a coverage badge without any service provider.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -26,3 +26,3 @@ const fetch = require('isomorphic-fetch');

const { emoji, text } = formatMessage(lastCoverage, coverage);
const { vcs, username, project, branch, ignoreSame } = others;
const { vcs, username, project, branch, ignoreSame, prs } = others;
let body = text;

@@ -42,2 +42,18 @@

if (prs) {
const PR_REGEX = /(?:\/|#)(\d+)\/?$/g;
const prsLinks = prs.split(',').map((pr) => {
const link = pr.trim();
if (link) {
const group = PR_REGEX.exec(link);
const prNum = group ? group[1] : null;
PR_REGEX.lastIndex = 0;
return prNum !== null ? `<${link}|#${prNum}>` : '';
}
}).filter(Boolean);
body += ` (${prsLinks.join(',')})`;
}
return fetch(webhook, {

@@ -44,0 +60,0 @@ method: 'POST',

@@ -72,1 +72,39 @@ import fetch from 'isomorphic-fetch';

});
describe('PR', () => {
afterEach(() => {
fetch.mockClear();
});
it('should process one pr', async () => {
await sendSlackWebhook('slack', 50, 100, {
prs: 'https://github.com/kevin940726/coverbadge/pull/2',
});
expect(fetch.mock.calls).toMatchSnapshot();
});
it('should process multiple prs', async () => {
await sendSlackWebhook('slack', 50, 100, {
prs: 'https://github.com/kevin940726/coverbadge/pull/1, https://github.com/kevin940726/coverbadge/pull/2',
});
expect(fetch.mock.calls).toMatchSnapshot();
});
it('should handle link error', async () => {
await sendSlackWebhook('slack', 50, 100, {
prs: 'https://github.com/kevin940726/coverbadge/pull/1,',
});
expect(fetch.mock.calls).toMatchSnapshot();
});
it('should handle regex error', async () => {
await sendSlackWebhook('slack', 50, 100, {
prs: 'https://github.com/kevin940726/coverbadge/pull/1x,https://github.com/kevin940726/coverbadge/pull/2',
});
expect(fetch.mock.calls).toMatchSnapshot();
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc