Skip to content

Instantly share code, notes, and snippets.

@eyaleizenberg
Last active June 12, 2019 05:21
Show Gist options
  • Save eyaleizenberg/3260e9aea63dcb0bbd094114b2a320d1 to your computer and use it in GitHub Desktop.
Save eyaleizenberg/3260e9aea63dcb0bbd094114b2a320d1 to your computer and use it in GitHub Desktop.
import { HelloPerson, Props } from './hello_person.component';
import { shallow } from 'enzyme';
import * as dataService from '../services/data-service';
export class HelloPersonDriver {
private wrapper;
private props: Props = {
name: 'some name'
}
given = {
name: (value: string): this => {
this.props.name = value;
return this;
}
};
when = {
rendered: (): this => {
jest.spyOn(dataService, 'reportUserLogin').mockReturnValue(Promise.resolve('OK'));
this.wrapper = shallow<HelloPerson>(<HelloPerson {...this.props} />);
return this;
}
};
get = {
renderedName: (): string => this.wrapper.find('#name').text(),
reportSpy: () => dataService.reportUserLogin
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment