Created
April 5, 2017 18:10
-
-
Save carlosble/14a0068b9fe81c655992f6267c8b0a45 to your computer and use it in GitHub Desktop.
Refactoring the test
This file contains 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
it("saves the profile in the backend", (done) => { | |
simulateChangeInPhone(change); | |
let savedProfile = spyOnSaveProfile(); | |
eventually(() => { | |
expect(savedProfile.phone).toEqual(change); | |
}, done); | |
saveProfileButton().simulate("click"); | |
}); | |
function spyOnSaveProfile(){ | |
let actualProfile = {}; | |
stubApi.saveProfile = (profile) => { | |
Object.assign(actualProfile, profile); | |
return Promise.resolve({message: 'Success'}); | |
}; | |
return actualProfile; | |
} | |
function eventually(expectation, done){ | |
spyNotifier.slowOperationFinished = () => { | |
expectation(); | |
done(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment