Skip to content

Commit

Permalink
feat(test): u#2860 t#4035 workflow edit
Browse files Browse the repository at this point in the history
  • Loading branch information
cocotime committed Oct 2, 2023
1 parent b423696 commit e42120c
Showing 1 changed file with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ import { Action } from '@ngrx/store';
import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { TuiNotification } from '@taiga-ui/core';
import { ProjectApiService } from '@taiga/api';
import { ProjectMockFactory, UserMockFactory } from '@taiga/data';
import {
ProjectMockFactory,
UserMockFactory,
WorkflowMockFactory,
} from '@taiga/data';
import { cold, hot } from 'jest-marbles';
import { Observable, of } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
Expand All @@ -30,6 +34,8 @@ import {
projectEventActions,
leaveProject,
leaveProjectSuccess,
updateWorkflow,
projectApiActions,
} from '../actions/project.actions';
import { selectCurrentProject } from '../selectors/project.selectors';
import { ProjectEffects } from './project.effects';
Expand Down Expand Up @@ -294,5 +300,35 @@ describe('ProjectEffects', () => {
expect(router.navigate).toHaveBeenCalledWith(['/']);
});
});

it('update workflow', () => {
const projectApiService = spectator.inject(ProjectApiService);
const effects = spectator.inject(ProjectEffects);
const workflow = WorkflowMockFactory();
const newWorkflowName = randCompanyName();
const workflowSuccess = {
...workflow,
name: newWorkflowName,
};

projectApiService.updateWorkflow.mockReturnValue(
cold('-b|', { b: workflowSuccess })
);

actions$ = hot('-a', {
a: updateWorkflow({
name: newWorkflowName,
slug: workflow.slug,
}),
});

const expected = cold('--a', {
a: projectApiActions.updateWorkflowSuccess({
workflow: workflowSuccess,
}),
});

expect(effects.updateWorkflow$).toBeObservable(expected);
});
});
});

0 comments on commit e42120c

Please sign in to comment.