Skip to content

Instantly share code, notes, and snippets.

@gparlakov
Created July 12, 2019 12:26
describe('TempUserService', () => {
it('when we call read without a temp user in there should read null', () => {
// arrange
const c = setup().build();
// act
const result = c.readEmail();
// assert
expect(result == null).toBe(true);
});
});
function setup() {
// the autospy VVVVV will create an object with the methods of the class mocked
const localStorage = autoSpy(Storage);
const builder = {
localStorage,
build() {
return new TempUserService(localStorage);
},
};
return builder;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment