2020-08-15 04:40:56 +00:00
|
|
|
import { expect } from 'chai';
|
2020-08-22 15:24:50 +00:00
|
|
|
import { Container, NullLogger } from 'noicejs';
|
2020-08-20 22:08:57 +00:00
|
|
|
import { alea } from 'seedrandom';
|
|
|
|
import { stub } from 'sinon';
|
|
|
|
|
|
|
|
import { GithubRemote } from '../../src/remote/github';
|
|
|
|
import { syncIssueLabels } from '../../src/sync';
|
2020-08-15 04:40:56 +00:00
|
|
|
|
|
|
|
describe('issue sync', () => {
|
2020-08-20 22:08:57 +00:00
|
|
|
it('should resolve each issue', async () => {
|
2020-08-22 15:24:50 +00:00
|
|
|
const container = Container.from();
|
|
|
|
await container.configure();
|
|
|
|
|
2020-08-20 22:08:57 +00:00
|
|
|
const logger = NullLogger.global;
|
|
|
|
const remoteData = {
|
2020-08-22 15:24:50 +00:00
|
|
|
container,
|
2020-08-20 22:08:57 +00:00
|
|
|
data: {},
|
|
|
|
dryrun: true,
|
|
|
|
logger,
|
|
|
|
type: '',
|
|
|
|
};
|
|
|
|
const remote = new GithubRemote(remoteData);
|
|
|
|
const listStub = stub(remote, 'listIssues').returns(Promise.resolve([{
|
|
|
|
issue: '',
|
|
|
|
labels: ['nope'],
|
|
|
|
name: '',
|
|
|
|
project: 'foo',
|
|
|
|
}]));
|
|
|
|
const updateStub = stub(remote, 'updateIssue').returns(Promise.resolve({
|
|
|
|
issue: '',
|
|
|
|
labels: [],
|
|
|
|
name: '',
|
|
|
|
project: '',
|
|
|
|
}));
|
|
|
|
|
|
|
|
await syncIssueLabels({
|
|
|
|
logger,
|
|
|
|
project: {
|
|
|
|
colors: [],
|
|
|
|
comment: false,
|
|
|
|
flags: [{
|
|
|
|
adds: [],
|
|
|
|
name: 'nope',
|
|
|
|
priority: 0,
|
|
|
|
removes: [],
|
|
|
|
requires: [{
|
|
|
|
name: 'yep',
|
|
|
|
}],
|
|
|
|
}],
|
|
|
|
name: 'foo',
|
|
|
|
remote: remoteData,
|
|
|
|
states: [],
|
|
|
|
},
|
|
|
|
random: alea(),
|
|
|
|
remote,
|
|
|
|
});
|
|
|
|
expect(listStub).to.have.callCount(1);
|
|
|
|
expect(updateStub).to.have.callCount(1);
|
|
|
|
expect(updateStub).to.have.been.calledWithMatch({
|
|
|
|
project: 'foo',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-08-15 04:40:56 +00:00
|
|
|
it('should update issues with label changes');
|
|
|
|
});
|