add test stubs
This commit is contained in:
parent
39a7091ac3
commit
b404ecf62e
|
@ -41,6 +41,6 @@ export declare class GithubRemote implements Remote
|
|||
| [listIssues(options)](./cautious-journey.githubremote.listissues.md) | | |
|
||||
| [listLabels(options)](./cautious-journey.githubremote.listlabels.md) | | |
|
||||
| [splitProject(project)](./cautious-journey.githubremote.splitproject.md) | | |
|
||||
| [updateIssue()](./cautious-journey.githubremote.updateissue.md) | | |
|
||||
| [updateIssue(options)](./cautious-journey.githubremote.updateissue.md) | | |
|
||||
| [updateLabel(options)](./cautious-journey.githubremote.updatelabel.md) | | |
|
||||
|
||||
|
|
|
@ -7,8 +7,15 @@
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
updateIssue(): Promise<IssueUpdate>;
|
||||
updateIssue(options: IssueUpdate): Promise<IssueUpdate>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| options | IssueUpdate | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
Promise<IssueUpdate>
|
||||
|
|
|
@ -140,8 +140,22 @@ export class GithubRemote implements Remote {
|
|||
return labels;
|
||||
}
|
||||
|
||||
public async updateIssue(): Promise<IssueUpdate> {
|
||||
throw new NotImplementedError();
|
||||
public async updateIssue(options: IssueUpdate): Promise<IssueUpdate> {
|
||||
const path = await this.splitProject(options.project);
|
||||
|
||||
if (this.writeCapable) {
|
||||
const data = await this.writeRequest.issues.setLabels({
|
||||
/* eslint-disable-next-line camelcase */
|
||||
issue_number: parseInt(options.issue, 10),
|
||||
labels: options.labels,
|
||||
owner: path.owner,
|
||||
repo: path.repo,
|
||||
});
|
||||
|
||||
this.options.logger.info({ data }, 'updated issue');
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
public async updateLabel(options: LabelUpdate): Promise<LabelUpdate> {
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
import { expect } from 'chai';
|
||||
|
||||
import { getLabelNames } from '../src/labels';
|
||||
|
||||
describe('labels', () => {
|
||||
describe('label name helper', () => {
|
||||
it('should return an empty set', () => {
|
||||
expect(getLabelNames([], []).size).to.equal(0);
|
||||
});
|
||||
|
||||
it('should return all flags', () => {
|
||||
const flags = [{
|
||||
adds: [],
|
||||
name: 'foo',
|
||||
priority: 1,
|
||||
removes: [],
|
||||
requires: [],
|
||||
}, {
|
||||
adds: [],
|
||||
name: 'bar',
|
||||
priority: 1,
|
||||
removes: [],
|
||||
requires: [],
|
||||
}];
|
||||
const names = flags.map((f) => f.name);
|
||||
|
||||
const labels = getLabelNames(flags, []);
|
||||
expect(Array.from(labels)).to.deep.equal(names);
|
||||
});
|
||||
|
||||
it('should return all states', () => {
|
||||
const values = [{
|
||||
becomes: [],
|
||||
name: 'bin',
|
||||
priority: 1,
|
||||
requires: [],
|
||||
}];
|
||||
const states = [{
|
||||
adds: [],
|
||||
name: 'foo',
|
||||
priority: 1,
|
||||
removes: [],
|
||||
requires: [],
|
||||
values,
|
||||
}, {
|
||||
adds: [],
|
||||
name: 'bar',
|
||||
priority: 1,
|
||||
removes: [],
|
||||
requires: [],
|
||||
values,
|
||||
}];
|
||||
|
||||
const labels = getLabelNames([], states);
|
||||
expect(Array.from(labels)).to.deep.equal([
|
||||
'foo/bin',
|
||||
'bar/bin',
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,17 @@
|
|||
import { expect } from 'chai';
|
||||
|
||||
import { defaultTo } from '../src/utils';
|
||||
|
||||
const TEST_TRUE = 'foo';
|
||||
const TEST_FALSE = 'bar';
|
||||
|
||||
describe('utils', () => {
|
||||
describe('default to value helper', () => {
|
||||
it('should return the first defined value', () => {
|
||||
/* eslint-disable-next-line no-null/no-null */
|
||||
expect(defaultTo(null, TEST_TRUE)).to.equal(TEST_TRUE);
|
||||
expect(defaultTo(undefined, TEST_TRUE)).to.equal(TEST_TRUE);
|
||||
expect(defaultTo(TEST_TRUE, TEST_FALSE)).to.equal(TEST_TRUE);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,13 @@
|
|||
import bunyan from 'bunyan';
|
||||
import { expect } from 'chai';
|
||||
|
||||
import { BunyanLogger } from '../../src/logger/bunyan';
|
||||
|
||||
describe('bunyan logger', async () => {
|
||||
it('should create a logger', async () => {
|
||||
const logger = BunyanLogger.create({
|
||||
name: 'test-logger',
|
||||
});
|
||||
expect(logger).to.be.an.instanceOf(bunyan);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
|
||||
describe('github remote', () => {
|
||||
it('should authenticate to Github API');
|
||||
});
|
|
@ -0,0 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
|
||||
describe('gitlab remote', () => {
|
||||
it('should authenticate to gitlab API');
|
||||
});
|
|
@ -0,0 +1,6 @@
|
|||
import { expect } from 'chai';
|
||||
|
||||
describe('issue sync', () => {
|
||||
it('should resolve each issue');
|
||||
it('should update issues with label changes');
|
||||
});
|
|
@ -0,0 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
|
||||
describe('label sync', () => {
|
||||
it('should sync each label');
|
||||
});
|
Loading…
Reference in New Issue