fix(test): cover label color selection and update
This commit is contained in:
parent
4aeb3243f7
commit
6229e2b46f
|
@ -1,10 +1,17 @@
|
|||
export const jsdom = require('jsdom-global')();
|
||||
const sourceMapSupport = require('source-map-support');
|
||||
|
||||
const sourceMapSupport = require('source-map-support');
|
||||
sourceMapSupport.install({
|
||||
environment: 'node',
|
||||
handleUncaughtExceptions: true,
|
||||
hookRequire: true,
|
||||
});
|
||||
|
||||
const chai = require('chai');
|
||||
const chaiPromise = require('chai-as-promised');
|
||||
const chaiSinon = require('sinon-chai');
|
||||
|
||||
chai.use(chaiPromise);
|
||||
chai.use(chaiSinon);
|
||||
|
||||
window.URL.createObjectURL = function () { };
|
||||
|
|
|
@ -1,5 +1,54 @@
|
|||
import { expect } from 'chai';
|
||||
import { alea } from 'seedrandom';
|
||||
import { match, spy } from 'sinon';
|
||||
|
||||
import { BunyanLogger } from '../../src/logger/bunyan';
|
||||
import { GithubRemote } from '../../src/remote/github';
|
||||
import { syncSingleLabel } from '../../src/sync';
|
||||
|
||||
describe('label sync', () => {
|
||||
it('should sync each label');
|
||||
it('should pick a stable random color for each label', async () => {
|
||||
const logger = BunyanLogger.create({
|
||||
name: 'test',
|
||||
});
|
||||
const remote = new GithubRemote({
|
||||
data: {},
|
||||
dryrun: true,
|
||||
logger,
|
||||
type: '',
|
||||
});
|
||||
const updateSpy = spy(remote, 'updateLabel');
|
||||
|
||||
await syncSingleLabel({
|
||||
colors: [
|
||||
'ff0000',
|
||||
],
|
||||
flags: [{
|
||||
adds: [],
|
||||
name: 'foo',
|
||||
priority: 1,
|
||||
removes: [],
|
||||
requires: [],
|
||||
}],
|
||||
logger,
|
||||
project: '',
|
||||
random: alea(),
|
||||
remote,
|
||||
states: [],
|
||||
}, {
|
||||
color: '',
|
||||
desc: '',
|
||||
name: 'foo',
|
||||
project: '',
|
||||
});
|
||||
|
||||
expect(updateSpy).to.have.callCount(1);
|
||||
|
||||
const COLOR_LENGTH = 6;
|
||||
expect(updateSpy).to.have.been.calledWithMatch({
|
||||
color: match.string.and(match((it) => it.length === COLOR_LENGTH)),
|
||||
name: 'foo',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue