invent-ed / devleague--behavior-driven-shopping-list

BDD Client Side Shopping List
0 stars 0 forks source link

assert the ShoppingList .items datatype #16

Open theRemix opened 7 years ago

theRemix commented 7 years ago

currently checking that myList.items.length is 0

this test would negatively pass if the class constructor looked like this

this.items = { length : 0 };

https://github.com/edsperanto/devleague--behavior-driven-shopping-list/blob/master/js/shopping_list_item_test.js#L60-L64

invent-ed commented 7 years ago

fixed this issue by adding new test that checks if myList.items is an array, because it should not be an object

theRemix commented 7 years ago

same issue here https://github.com/edsperanto/devleague--behavior-driven-shopping-list/blob/master/tests/shopping_list_test.js#L26

the test has the chance of negatively passing in this case

this.items = {
  length : 0,
  push : function(){}
};
invent-ed commented 7 years ago

@theRemix I don't understand what "negatively passing" means? do you mean its not supposed to pass when its constructed like this, or it SHOULD pass even if it's constructed like this?

theRemix commented 7 years ago

negatively passing => undesired behavior/implemention still passes the tests

If i were to alter ShoppingList to initialize the .items property as

this.items = {
  length : 0,
  push : function(){}
};

would mean that this code will pass while it clearly is not the desired implementation.

can you think of a better way to test what datatype the .items property should be?