Fix linting errors after #13392

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-08-30 13:43:57 +02:00
parent 3716ae33b2
commit aaab1e34da
151 changed files with 837 additions and 786 deletions
@@ -58,8 +58,8 @@ describe('ScaffolderEntitiesProcessor', () => {
await processor.postProcessEntity(mockEntity, mockLocation, emit);
expect(emit).toBeCalledTimes(2);
expect(emit).toBeCalledWith({
expect(emit).toHaveBeenCalledTimes(2);
expect(emit).toHaveBeenCalledWith({
type: 'relation',
relation: {
source: { kind: 'Group', namespace: 'default', name: 'o' },
@@ -67,7 +67,7 @@ describe('ScaffolderEntitiesProcessor', () => {
target: { kind: 'Template', namespace: 'default', name: 'n' },
},
});
expect(emit).toBeCalledWith({
expect(emit).toHaveBeenCalledWith({
type: 'relation',
relation: {
source: { kind: 'Template', namespace: 'default', name: 'n' },
@@ -107,11 +107,11 @@ describe('catalog:register', () => {
{},
);
expect(mockContext.output).toBeCalledWith(
expect(mockContext.output).toHaveBeenCalledWith(
'entityRef',
'component:default/test',
);
expect(mockContext.output).toBeCalledWith(
expect(mockContext.output).toHaveBeenCalledWith(
'catalogInfoUrl',
'http://foo/var',
);
@@ -160,7 +160,7 @@ describe('catalog:register', () => {
catalogInfoUrl: 'http://foo/var',
},
});
expect(mockContext.output).toBeCalledWith(
expect(mockContext.output).toHaveBeenCalledWith(
'entityRef',
'component:default/test',
);
@@ -202,7 +202,10 @@ describe('catalog:register', () => {
catalogInfoUrl: 'http://foo/var',
},
});
expect(mockContext.output).toBeCalledWith('entityRef', 'api:default/test');
expect(mockContext.output).toHaveBeenCalledWith(
'entityRef',
'api:default/test',
);
});
it('should return entityRef with the first entity if no non-generated entities can be found', async () => {
@@ -234,7 +237,7 @@ describe('catalog:register', () => {
catalogInfoUrl: 'http://foo/var',
},
});
expect(mockContext.output).toBeCalledWith(
expect(mockContext.output).toHaveBeenCalledWith(
'entityRef',
'location:default/generated-1238',
);
@@ -254,7 +257,7 @@ describe('catalog:register', () => {
catalogInfoUrl: 'http://foo/var',
},
});
expect(mockContext.output).not.toBeCalledWith(
expect(mockContext.output).not.toHaveBeenCalledWith(
'entityRef',
expect.any(String),
);
@@ -292,7 +295,7 @@ describe('catalog:register', () => {
{},
);
expect(mockContext.output).toBeCalledWith(
expect(mockContext.output).toHaveBeenCalledWith(
'catalogInfoUrl',
'http://foo/var',
);
@@ -54,7 +54,7 @@ describe('debug:log', () => {
it('should do nothing', async () => {
await action.handler(mockContext);
expect(logStream.write).toBeCalledTimes(0);
expect(logStream.write).toHaveBeenCalledTimes(0);
});
it('should log the workspace content, if active', async () => {
@@ -67,11 +67,11 @@ describe('debug:log', () => {
await action.handler(context);
expect(logStream.write).toBeCalledTimes(1);
expect(logStream.write).toBeCalledWith(
expect(logStream.write).toHaveBeenCalledTimes(1);
expect(logStream.write).toHaveBeenCalledWith(
expect.stringContaining('README.md'),
);
expect(logStream.write).toBeCalledWith(
expect(logStream.write).toHaveBeenCalledWith(
expect.stringContaining(join('a-directory', 'index.md')),
);
});
@@ -86,8 +86,8 @@ describe('debug:log', () => {
await action.handler(context);
expect(logStream.write).toBeCalledTimes(1);
expect(logStream.write).toBeCalledWith(
expect(logStream.write).toHaveBeenCalledTimes(1);
expect(logStream.write).toHaveBeenCalledWith(
expect.stringContaining('Hello Backstage!'),
);
});
@@ -81,7 +81,7 @@ describe('fetchContent helper', () => {
fetchUrl: 'foo',
outputPath: 'somepath',
});
expect(fs.copy).toBeCalledWith(resolvePath('/some/foo'), 'somepath');
expect(fs.copy).toHaveBeenCalledWith(resolvePath('/some/foo'), 'somepath');
});
it('should reject if no integration matches location', async () => {
@@ -116,7 +116,7 @@ describe('fetchContent helper', () => {
outputPath: 'foo',
fetchUrl: 'https://github.com/backstage/foo',
});
expect(fs.ensureDir).toBeCalled();
expect(dirFunction).toBeCalledWith({ targetDir: 'foo' });
expect(fs.ensureDir).toHaveBeenCalled();
expect(dirFunction).toHaveBeenCalledWith({ targetDir: 'foo' });
});
});
@@ -73,7 +73,7 @@ describe('fetch:plain', () => {
targetPath: 'lol',
},
});
expect(fetchContents).toBeCalledWith(
expect(fetchContents).toHaveBeenCalledWith(
expect.objectContaining({
outputPath: resolvePath(mockContext.workspacePath, 'lol'),
fetchUrl:
@@ -117,7 +117,7 @@ describe('fetch:template', () => {
it('throws if output directory is outside the workspace', async () => {
await expect(() =>
action.handler(mockContext({ targetPath: '../' })),
).rejects.toThrowError(
).rejects.toThrow(
/relative path is not allowed to refer to a directory outside its parent/i,
);
});
@@ -127,7 +127,7 @@ describe('fetch:template', () => {
action.handler(
mockContext({ copyWithoutRender: 'abc' as unknown as string[] }),
),
).rejects.toThrowError(
).rejects.toThrow(
/copyWithoutRender\/copyWithoutTemplating must be an array/i,
);
});
@@ -140,7 +140,7 @@ describe('fetch:template', () => {
copyWithoutTemplating: 'def' as unknown as string[],
}),
),
).rejects.toThrowError(
).rejects.toThrow(
/copyWithoutRender and copyWithoutTemplating can not be used at the same time/i,
);
});
@@ -153,7 +153,7 @@ describe('fetch:template', () => {
templateFileExtension: true,
}),
),
).rejects.toThrowError(
).rejects.toThrow(
/input extension incompatible with copyWithoutRender\/copyWithoutTemplating and cookiecutterCompat/,
);
});
@@ -166,7 +166,7 @@ describe('fetch:template', () => {
templateFileExtension: true,
}),
),
).rejects.toThrowError(
).rejects.toThrow(
/input extension incompatible with copyWithoutRender\/copyWithoutTemplating and cookiecutterCompat/,
);
});
@@ -302,8 +302,8 @@ describe('createPublishGithubPullRequestAction', () => {
it('creates a pull request and requests a review from the given reviewers', async () => {
await instance.handler(ctx);
expect(fakeClient.createPullRequest).toBeCalled();
expect(fakeClient.rest.pulls.requestReviewers).toBeCalledWith({
expect(fakeClient.createPullRequest).toHaveBeenCalled();
expect(fakeClient.rest.pulls.requestReviewers).toHaveBeenCalledWith({
owner: 'myorg',
repo: 'myrepo',
pull_number: 123,
@@ -354,8 +354,8 @@ describe('createPublishGithubPullRequestAction', () => {
it('does not call the API endpoint for requesting reviewers', async () => {
await instance.handler(ctx);
expect(fakeClient.createPullRequest).toBeCalled();
expect(fakeClient.rest.pulls.requestReviewers).not.toBeCalled();
expect(fakeClient.createPullRequest).toHaveBeenCalled();
expect(fakeClient.rest.pulls.requestReviewers).not.toHaveBeenCalled();
});
});
@@ -128,7 +128,7 @@ describe('DefaultWorkflowRunner', () => {
steps: [{ id: 'test', name: 'name', action: 'does-not-exist' }],
});
await expect(runner.execute(task)).rejects.toThrowError(
await expect(runner.execute(task)).rejects.toThrow(
"Template action with ID 'does-not-exist' is not registered.",
);
});
@@ -142,7 +142,7 @@ describe('DefaultWorkflowRunner', () => {
steps: [{ id: 'test', name: 'name', action: 'jest-validated-action' }],
});
await expect(runner.execute(task)).rejects.toThrowError(
await expect(runner.execute(task)).rejects.toThrow(
/Invalid input passed to action jest-validated-action, instance requires property \"foo\"/,
);
});
@@ -410,7 +410,7 @@ describe('createRouter', () => {
});
const response = await request(app).get(`/v2/tasks`);
expect(taskBroker.list).toBeCalledWith({
expect(taskBroker.list).toHaveBeenCalledWith({
createdBy: undefined,
});
expect(response.status).toEqual(200);
@@ -445,7 +445,7 @@ describe('createRouter', () => {
const response = await request(app).get(
`/v2/tasks?createdBy=user:default/foo`,
);
expect(taskBroker.list).toBeCalledWith({
expect(taskBroker.list).toHaveBeenCalledWith({
createdBy: 'user:default/foo',
});
@@ -545,18 +545,18 @@ describe('createRouter', () => {
expect(statusCode).toBe(200);
expect(headers['content-type']).toBe('text/event-stream');
expect(responseDataFn).toBeCalledTimes(2);
expect(responseDataFn).toBeCalledWith(`event: log
expect(responseDataFn).toHaveBeenCalledTimes(2);
expect(responseDataFn).toHaveBeenCalledWith(`event: log
data: {"id":0,"taskId":"a-random-id","type":"log","createdAt":"","body":{"message":"My log message"}}
`);
expect(responseDataFn).toBeCalledWith(`event: completion
expect(responseDataFn).toHaveBeenCalledWith(`event: completion
data: {"id":1,"taskId":"a-random-id","type":"completion","createdAt":"","body":{"message":"Finished!"}}
`);
expect(taskBroker.event$).toBeCalledTimes(1);
expect(taskBroker.event$).toBeCalledWith({ taskId: 'a-random-id' });
expect(taskBroker.event$).toHaveBeenCalledTimes(1);
expect(taskBroker.event$).toHaveBeenCalledWith({ taskId: 'a-random-id' });
expect(subscriber!.closed).toBe(true);
});
@@ -607,8 +607,8 @@ data: {"id":1,"taskId":"a-random-id","type":"completion","createdAt":"","body":{
expect(statusCode).toBe(200);
expect(headers['content-type']).toBe('text/event-stream');
expect(taskBroker.event$).toBeCalledTimes(1);
expect(taskBroker.event$).toBeCalledWith({
expect(taskBroker.event$).toHaveBeenCalledTimes(1);
expect(taskBroker.event$).toHaveBeenCalledWith({
taskId: 'a-random-id',
after: 10,
});
@@ -666,8 +666,8 @@ data: {"id":1,"taskId":"a-random-id","type":"completion","createdAt":"","body":{
},
]);
expect(taskBroker.event$).toBeCalledTimes(1);
expect(taskBroker.event$).toBeCalledWith({ taskId: 'a-random-id' });
expect(taskBroker.event$).toHaveBeenCalledTimes(1);
expect(taskBroker.event$).toHaveBeenCalledWith({ taskId: 'a-random-id' });
expect(subscriber!.closed).toBe(true);
});
@@ -689,8 +689,8 @@ data: {"id":1,"taskId":"a-random-id","type":"completion","createdAt":"","body":{
expect(response.status).toEqual(200);
expect(response.body).toEqual([]);
expect(taskBroker.event$).toBeCalledTimes(1);
expect(taskBroker.event$).toBeCalledWith({
expect(taskBroker.event$).toHaveBeenCalledTimes(1);
expect(taskBroker.event$).toHaveBeenCalledWith({
taskId: 'a-random-id',
after: 10,
});