Added a unit test

Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
bnechyporenko
2022-09-08 11:00:55 +02:00
parent 820628b17f
commit 63b0626c9d
@@ -66,7 +66,7 @@ describe('DefaultWorkflowRunner', () => {
});
beforeEach(() => {
winston.format.simple(); // put logform the require cache before mocking fs
winston.format.simple(); // put logform the required cache before mocking fs
mockFs({
'/tmp': mockFs.directory(),
...realFiles,
@@ -169,6 +169,21 @@ describe('DefaultWorkflowRunner', () => {
it('should pass metadata through', async () => {
const entityRef = `template:default/templateName`;
const userEntity: UserEntity = {
apiVersion: 'backstage.io/v1beta1',
kind: 'User',
metadata: {
name: 'user',
},
spec: {
profile: {
displayName: 'Bogdan Nechyporenko',
email: 'bnechyporenko@company.com',
},
},
};
const task = createMockTaskWithSpec({
apiVersion: 'scaffolder.backstage.io/v1beta3',
parameters: {},
@@ -182,6 +197,9 @@ describe('DefaultWorkflowRunner', () => {
},
],
templateInfo: { entityRef },
user: {
entity: userEntity,
},
});
await runner.execute(task);
@@ -189,6 +207,10 @@ describe('DefaultWorkflowRunner', () => {
expect(fakeActionHandler.mock.calls[0][0].templateInfo).toEqual({
entityRef,
});
expect(fakeActionHandler.mock.calls[0][0].user).toEqual({
entity: userEntity,
});
});
it('should pass token through', async () => {