Skip to content

Commit

Permalink
remove update-handler from ReflowAssessmentView
Browse files Browse the repository at this point in the history
  • Loading branch information
pownkel committed May 15, 2020
1 parent 3acb8ab commit ffa56e2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 63 deletions.
24 changes: 2 additions & 22 deletions src/DetailsView/components/reflow-assessment-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
// Licensed under the MIT License.
import * as React from 'react';

import {
AssessmentViewUpdateHandler,
AssessmentViewUpdateHandlerDeps,
AssessmentViewUpdateHandlerProps,
} from 'DetailsView/components/assessment-view-update-handler';
import { AssessmentTestResult } from '../../common/assessment/assessment-test-result';
import { Tab } from '../../common/itab';
import {
Expand All @@ -17,10 +12,7 @@ import {
import { GettingStartedView } from './getting-started-view';
import { TargetChangeDialog, TargetChangeDialogDeps } from './target-change-dialog';

export type ReflowAssessmentViewDeps = {
assessmentViewUpdateHandler: AssessmentViewUpdateHandler;
} & AssessmentViewUpdateHandlerDeps &
TargetChangeDialogDeps;
export type ReflowAssessmentViewDeps = TargetChangeDialogDeps;

export type ReflowAssessmentViewProps = {
deps: ReflowAssessmentViewDeps;
Expand All @@ -29,7 +21,7 @@ export type ReflowAssessmentViewProps = {
currentTarget: Tab;
prevTarget: PersistedTabInfo;
assessmentTestResult: AssessmentTestResult;
} & AssessmentViewUpdateHandlerProps;
};

export class ReflowAssessmentView extends React.Component<ReflowAssessmentViewProps> {
public render(): JSX.Element {
Expand All @@ -47,18 +39,6 @@ export class ReflowAssessmentView extends React.Component<ReflowAssessmentViewPr
return null;
}

public componentDidMount(): void {
this.props.deps.assessmentViewUpdateHandler.onMount(this.props);
}

public componentDidUpdate(prevProps: ReflowAssessmentViewProps): void {
this.props.deps.assessmentViewUpdateHandler.update(prevProps, this.props);
}

public componentWillUnmount(): void {
this.props.deps.assessmentViewUpdateHandler.onUnmount(this.props);
}

private renderTargetChangeDialog(): JSX.Element {
return (
<TargetChangeDialog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
exports[`AssessmentViewTest render for gettting started 1`] = `
<div>
<TargetChangeDialog
deps={
Object {
"assessmentViewUpdateHandler": proxy {
"___id": "BCDF5CE5-F0DF-40B7-8BA0-69DF395033C8",
},
}
}
deps={Object {}}
newTab={
Object {
"id": 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,6 @@ describe('AssessmentViewTest', () => {
expect(rendered.getElement()).toMatchSnapshot();
});

test('componentDidMount', () => {
const props = generateProps('requirement');
updateHandlerMock.setup(u => u.onMount(props)).verifiable(Times.once());
const testObject = new ReflowAssessmentView(props);

testObject.componentDidMount();

updateHandlerMock.verifyAll();
});

test('componentWillUnmount', () => {
const props = generateProps('requirement');
updateHandlerMock.setup(u => u.onUnmount(props)).verifiable(Times.once());
const testObject = new ReflowAssessmentView(props);

testObject.componentWillUnmount();

updateHandlerMock.verifyAll();
});

test('componentDidUpdate', () => {
const prevProps = generateProps('requirement1');
const props = generateProps('requirement2');
updateHandlerMock.setup(u => u.update(prevProps, props)).verifiable(Times.once());
const testObject = new ReflowAssessmentView(props);

testObject.componentDidUpdate(prevProps);

updateHandlerMock.verifyAll();
});

function generateProps(subview: string): ReflowAssessmentViewProps {
const assessmentDataMock = Mock.ofType<AssessmentData>();

Expand All @@ -73,9 +42,7 @@ describe('AssessmentViewTest', () => {
} as AssessmentTestResult;

const reflowProps = {
deps: {
assessmentViewUpdateHandler: updateHandlerMock.object,
} as ReflowAssessmentViewDeps,
deps: {} as ReflowAssessmentViewDeps,
prevTarget: { id: 4 },
currentTarget: { id: 5 },
assessmentNavState: {
Expand Down

0 comments on commit ffa56e2

Please sign in to comment.