Reputation: 14204
I fear I do not fully understand JavaScrpt variable scoping. I have a function that looks like this:
return {
response: '',
birthMonthPrompt: function(question, promptCallback) {
this.dialogText = question;
}
};
The idea is that birthMonthPrompt will ask a user for their birth month. After they enter it, I will have a value like 'November'. To test ths, I've written the following:
it('should prompt the user', function() {
var reponse = 'November';
myService.response= response;
myService.birthMonthPrompt('Please choose your birth month:',
function(userResponse) {
expect(userResponse).toBe(this.response);
}
);
});
When I execute this, I get an error that says:
ReferenceError: Can't find variable: response
I don't understand why my test can't find response. What am I doing wrong?
Upvotes: 1
Views: 225
Reputation: 128776
You have a typo:
var reponse = 'November';
Should be:
var response = 'November';
Upvotes: 1