Skip to content

Commit

Permalink
Added unit tests for new controller methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rladdusaw committed Sep 11, 2020
1 parent 3248cdf commit b6da27e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/unit/controllers/productControllerTest.js
Expand Up @@ -315,6 +315,33 @@ describe("controller: ProductController", function () {
expect(product.save).toHaveBeenCalled();
});

it("addOtherUrl adds another url to the array", function () {
var product = new mockProduct($q);
product.mock({
otherUrls: []
});

spyOn(product.otherUrls, "push");

$scope.addOtherUrl(product);

expect(product.otherUrls.push).toHaveBeenCalled();
});

it("removeOtherUrl removes the other url at the given index", function () {
var product = new mockProduct($q);
product.mock({
otherUrls: [ "First url", "Second url", "Third url" ]
});

spyOn(product.otherUrls, "splice");
spyOn($scope, "otherUrlsChanged");
$scope.removeOtherUrl(product, 1);

expect($scope.otherUrlsChanged).toEqual(true);
expect(product.otherUrls.splice).toHaveBeenCalled();
});

});

});

0 comments on commit b6da27e

Please sign in to comment.