Last active
June 12, 2019 05:21
-
-
Save eyaleizenberg/3260e9aea63dcb0bbd094114b2a320d1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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