Files
shields/gh-badges/lib/badge-cli.spec.js
chris48s b68ac16092 Move NPM package files out of /lib ; affects [resharper nuget myget dub chocolatey github] (#2300)
* move gh-badges files out of /lib

As far as possible, this is just moving files
around and updating paths however there are 2
functional changes in this commit:
- remove use of lib/register-chai-plugins.spec
  in badge-cli.spec.js
- remove use of starRating()
  in text-measurer.spec.js

* update service tests that use colorscheme.json

* split package.json in two

* clean up import

* don't hard-code path

* start a changelog

* put a license file in the package dir

* re-organise documentation 📚

* don't pack test files

* remove favicon from Makefile

* give package its own test command

* link the docs better in README
2018-11-15 18:48:01 +00:00

59 lines
1.5 KiB
JavaScript

'use strict'
const path = require('path')
const isPng = require('is-png')
const isSvg = require('is-svg')
const { spawn } = require('child-process-promise')
const { expect, use } = require('chai')
use(require('chai-string'))
use(require('sinon-chai'))
function runCli(args) {
return spawn('node', [path.join(__dirname, 'badge-cli.js'), ...args], {
capture: ['stdout'],
})
}
describe('The CLI', function() {
it('should provide a help message', async function() {
const { stdout } = await runCli([])
expect(stdout).to.startWith('Usage')
})
it('should produce default badges', async function() {
const { stdout } = await runCli(['cactus', 'grown'])
expect(stdout)
.to.satisfy(isSvg)
.and.to.include('cactus')
.and.to.include('grown')
})
it('should produce colorschemed badges', async function() {
const { stdout } = await runCli(['cactus', 'grown', ':green'])
expect(stdout).to.satisfy(isSvg)
})
it('should produce right-color badges', async function() {
const { stdout } = await runCli(['cactus', 'grown', '#abcdef'])
expect(stdout)
.to.satisfy(isSvg)
.and.to.include('#abcdef')
})
it('should produce PNG badges', async function() {
const child = runCli(['cactus', 'grown', '.png'])
// The buffering done by `child-process-promise` doesn't seem correctly to
// handle binary data.
let chunk
child.childProcess.stdout.once('data', data => {
chunk = data
})
await child
expect(chunk).to.satisfy(isPng)
})
})