1
0
Fork 0
cautious-journey/test/sync/TestSyncLabels.ts

55 lines
1.2 KiB
TypeScript
Raw Normal View History

2020-08-15 04:40:56 +00:00
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';
2020-08-15 04:40:56 +00:00
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',
});
});
2020-08-15 04:40:56 +00:00
});