Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homework 3 - Last Question #11

Open
JourdanClark opened this issue Aug 30, 2017 · 1 comment
Open

Homework 3 - Last Question #11

JourdanClark opened this issue Aug 30, 2017 · 1 comment

Comments

@JourdanClark
Copy link

JourdanClark commented Aug 30, 2017

Homework 3: addCalculateDiscountPriceMethod(storeItem)

Instructions don't say to return storeItem, but the tests fail if we don't. I think either return storeItem should be specified in the instructions in exercises.js, or the test should be changed to this:

var storeItem = {
  price: 80,
  discountPercentage: 0.1
};
var storeItem2 = {
  price: 5,
  discountPercentage: 0.5
};

exercises.addCalculateDiscountPriceMethod(storeItem);
exercises.addCalculateDiscountPriceMethod(storeItem2);

it('should add the method \'calculateDiscountPrice\' to the store item object', function() {
  expect(storeItem.calculateDiscountPrice).toBeDefined();
  expect(storeItem2.calculateDiscountPrice).toBeDefined();
});

it('should return the discount price from the new \'calculateDiscountPrice\' method', function() {
  expect(storeItem.calculateDiscountPrice()).toBe(72);
  expect(storeItem2.calculateDiscountPrice()).toBe(2.5);
});

Right now the tests do this, where it's using the return from our function instead of the storeItems that are in the test.js expect(exercises.addCalculateDiscountPriceMethod(storeItem).calculateDiscountPrice).toBeDefined();

The other exercises specify whether or not to return something so I think it confuses people when this one doesn't say to return something, even though it is expecting you to.

The changes to the test.js that I'm proposing have been tested and work as expected. It allows us to modify the storeItem that's passed into our function and we don't need to return it for the tests to pass.

@ghost
Copy link

ghost commented Nov 9, 2017

@JourdanClark I concur with this. The test should be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant