Upgrading AngularJS specs to Jasmine 2 syntax

This commit is contained in:
Rob Harrington
2016-05-01 21:10:28 +10:00
parent cfbfe8416f
commit 7a498362b3
28 changed files with 177 additions and 173 deletions

View File

@@ -8,9 +8,10 @@ describe "CustomersCtrl", ->
scope = $rootScope
http = $httpBackend
$controller 'customersCtrl', {$scope: scope, CustomerResource: _CustomerResource_, shops: {}}
this.addMatchers
toAngularEqual: (expected) ->
return angular.equals(this.actual, expected)
jasmine.addMatchers
toDeepEqual: (util, customEqualityTesters) ->
compare: (actual, expected) ->
{ pass: angular.equals(actual, expected) }
it "has no shop pre-selected", ->
expect(scope.shop).toEqual {}
@@ -26,7 +27,7 @@ describe "CustomersCtrl", ->
http.flush()
it "retrievs the list of customers", ->
expect(scope.customers).toAngularEqual customers
expect(scope.customers).toDeepEqual customers
describe "scope.add", ->
it "creates a new customer", ->
@@ -36,7 +37,7 @@ describe "CustomersCtrl", ->
http.expectPOST('/admin/customers.json?email=' + email + '&enterprise_id=1').respond 200, newCustomer
scope.add(email)
http.flush()
expect(scope.customers).toAngularEqual customers
expect(scope.customers).toDeepEqual customers
describe "scope.deleteCustomer", ->
it "deletes a customer", ->
@@ -46,7 +47,7 @@ describe "CustomersCtrl", ->
scope.deleteCustomer(customer)
http.flush()
expect(scope.customers.length).toBe 1
expect(scope.customers[0]).not.toAngularEqual customer
expect(scope.customers[0]).not.toDeepEqual customer
describe "scope.findTags", ->
tags = [
@@ -63,7 +64,7 @@ describe "CustomersCtrl", ->
promise.then (data) ->
result = data
http.flush()
expect(result).toAngularEqual tags
expect(result).toDeepEqual tags
it "filters the tag list", ->
filtered_tags = [
@@ -75,4 +76,4 @@ describe "CustomersCtrl", ->
promise.then (data) ->
result = data
http.flush()
expect(result).toAngularEqual filtered_tags
expect(result).toDeepEqual filtered_tags

View File

@@ -53,7 +53,7 @@ describe "enterpriseCtrl", ->
expect(enterprise.users).not.toContain u4
it "ignores objects that are already in the list, and alerts the user", ->
spyOn(window, "alert").andCallThrough()
spyOn(window, "alert").and.callThrough()
u4 = { id: 3, email: "email-doesn't-matter.com" }
scope.addManager u4
expect(enterprise.users).not.toContain u4

View File

@@ -8,7 +8,7 @@ describe "EnterprisesCtrl", ->
inject ($controller, $rootScope, _Enterprises_) ->
scope = $rootScope
Enterprises = _Enterprises_
spyOn(Enterprises, "index").andReturn "list of enterprises"
spyOn(Enterprises, "index").and.returnValue "list of enterprises"
ctrl = $controller 'enterprisesCtrl', {$scope: scope, Enterprises: Enterprises}
describe "setting the shop on scope", ->

View File

@@ -20,10 +20,10 @@ describe "indexPanelCtrl", ->
deferred = null
beforeEach inject ($q) ->
spyOn(scope, "saved").andReturn false
spyOn(scope, "saved").and.returnValue false
spyOn(scope, "$emit")
deferred = $q.defer()
spyOn(Enterprises, "save").andReturn(deferred.promise)
spyOn(Enterprises, "save").and.returnValue(deferred.promise)
scope.save()
it "sets scope.saving to true", ->

View File

@@ -28,21 +28,21 @@ describe "permalinkCtrl", ->
it "sends a request to PermalinkChecker when permalink is changed", ->
deferred.resolve("")
promise = deferred.promise
spyOn(PermalinkChecker, "check").andReturn promise
spyOn(PermalinkChecker, "check").and.returnValue promise
$scope.$apply Enterprise.permalink = "somethingelse" # Change the permalink
expect(PermalinkChecker.check).toHaveBeenCalled()
it "sets available to '' when PermalinkChecker resolves permalink to the existing permalink on Enterprise ", ->
deferred.resolve({permalink: "something"})
promise = deferred.promise
spyOn(PermalinkChecker, "check").andReturn promise
spyOn(PermalinkChecker, "check").and.returnValue promise
$scope.$apply Enterprise.permalink = "somethingelse" # Change the permalink
expect($scope.availability).toEqual ""
it "sets available and permalink when PermalinkChecker resolves", ->
deferred.resolve({ available: "Available", permalink: "permalink"})
promise = deferred.promise
spyOn(PermalinkChecker, "check").andReturn promise
spyOn(PermalinkChecker, "check").and.returnValue promise
$scope.$apply Enterprise.permalink = "somethingelse" # Change the permalink
expect(Enterprise.permalink).toEqual "permalink"
expect($scope.availability).toEqual "Available"
@@ -51,7 +51,7 @@ describe "permalinkCtrl", ->
$scope.availability = "Some Availability"
deferred.reject()
promise = deferred.promise
spyOn(PermalinkChecker, "check").andReturn promise
spyOn(PermalinkChecker, "check").and.returnValue promise
$scope.$apply Enterprise.permalink = "somethingelse" # Change the permalink
expect($scope.availability).toEqual "Some Availability"
expect(Enterprise.permalink).toEqual "somethingelse"

View File

@@ -17,8 +17,8 @@ describe "menuCtrl", ->
inject ($rootScope, $controller, _SideMenu_) ->
scope = $rootScope
SideMenu = _SideMenu_
spyOn(SideMenu, "select").andCallThrough()
spyOn(SideMenu, "setItems").andCallThrough()
spyOn(SideMenu, "select").and.callThrough()
spyOn(SideMenu, "setItems").and.callThrough()
ctrl = $controller 'sideMenuCtrl', {$scope: scope, enterprise: enterprise, SideMenu: SideMenu, enterprisePermissions: {}}
describe "initialisation", ->

View File

@@ -27,16 +27,16 @@ describe "EnterprisePaymentMethods service", ->
describe "determining payment method colour", ->
it "returns 'blue' when at least one payment method is selected", ->
spyOn(EnterprisePaymentMethods, "selectedCount").andReturn 1
spyOn(EnterprisePaymentMethods, "selectedCount").and.returnValue 1
expect(EnterprisePaymentMethods.displayColor()).toBe "blue"
it "returns 'red' when no payment methods are selected", ->
spyOn(EnterprisePaymentMethods, "selectedCount").andReturn 0
spyOn(EnterprisePaymentMethods, "selectedCount").and.returnValue 0
expect(EnterprisePaymentMethods.displayColor()).toBe "red"
it "returns 'red' when no payment methods exist", ->
EnterprisePaymentMethods.paymentMethods = []
spyOn(EnterprisePaymentMethods, "selectedCount").andReturn 1
spyOn(EnterprisePaymentMethods, "selectedCount").and.returnValue 1
expect(EnterprisePaymentMethods.displayColor()).toBe "red"
describe "counting selected payment methods", ->

View File

@@ -27,16 +27,16 @@ describe "EnterpriseShippingMethods service", ->
describe "determining shipping method colour", ->
it "returns 'blue' when at least one shipping method is selected", ->
spyOn(EnterpriseShippingMethods, "selectedCount").andReturn 1
spyOn(EnterpriseShippingMethods, "selectedCount").and.returnValue 1
expect(EnterpriseShippingMethods.displayColor()).toBe "blue"
it "returns 'red' when no shipping methods are selected", ->
spyOn(EnterpriseShippingMethods, "selectedCount").andReturn 0
spyOn(EnterpriseShippingMethods, "selectedCount").and.returnValue 0
expect(EnterpriseShippingMethods.displayColor()).toBe "red"
it "returns 'red' when no shipping methods exist", ->
EnterpriseShippingMethods.shippingMethods = []
spyOn(EnterpriseShippingMethods, "selectedCount").andReturn 1
spyOn(EnterpriseShippingMethods, "selectedCount").and.returnValue 1
expect(EnterpriseShippingMethods.displayColor()).toBe "red"
describe "counting selected shipping methods", ->

View File

@@ -4,9 +4,10 @@ describe "Enterprises service", ->
beforeEach ->
module 'admin.enterprises'
this.addMatchers
toDeepEqual: (expected) ->
return angular.equals(this.actual, expected)
jasmine.addMatchers
toDeepEqual: (util, customEqualityTesters) ->
compare: (actual, expected) ->
{ pass: angular.equals(actual, expected) }
inject ($q, _$httpBackend_, _Enterprises_, _EnterpriseResource_) ->
Enterprises = _Enterprises_
@@ -98,14 +99,14 @@ describe "Enterprises service", ->
describe "#saved", ->
describe "when attributes of the object have been altered", ->
beforeEach ->
spyOn(Enterprises, "diff").andReturn ["attr1", "attr2"]
spyOn(Enterprises, "diff").and.returnValue ["attr1", "attr2"]
it "returns false", ->
expect(Enterprises.saved({})).toBe false
describe "when attributes of the object have not been altered", ->
beforeEach ->
spyOn(Enterprises, "diff").andReturn []
spyOn(Enterprises, "diff").and.returnValue []
it "returns false", ->
expect(Enterprises.saved({})).toBe true

View File

@@ -29,7 +29,7 @@ describe "Panels service", ->
describe "when no panel is currently selected", ->
beforeEach ->
scopeMock.getSelected = jasmine.createSpy('getSelected').andReturn(null)
scopeMock.getSelected = jasmine.createSpy('getSelected').and.returnValue(null)
Panels.toggle(12, 'panel_name')
it "calls #open on the scope", ->
@@ -37,7 +37,7 @@ describe "Panels service", ->
describe "when #toggle is called for the currently selected panel", ->
beforeEach ->
scopeMock.getSelected = jasmine.createSpy('getSelected').andReturn('panel_name')
scopeMock.getSelected = jasmine.createSpy('getSelected').and.returnValue('panel_name')
Panels.toggle(12, 'panel_name')
it "calls #close on the scope", ->
@@ -45,7 +45,7 @@ describe "Panels service", ->
describe "when #toggle is called for a different panel", ->
beforeEach ->
scopeMock.getSelected = jasmine.createSpy('getSelected').andReturn('some_other_panel_name')
scopeMock.getSelected = jasmine.createSpy('getSelected').and.returnValue('some_other_panel_name')
Panels.toggle(12, 'panel_name')
it "calls #setSelected on the scope", ->

View File

@@ -4,7 +4,7 @@ describe "Pending Changes", ->
beforeEach ->
resourcesMock =
update: jasmine.createSpy('update').andCallFake (change) ->
update: jasmine.createSpy('update').and.callFake (change) ->
$promise:
then: (successFn, errorFn) ->
return successFn({propertyName: "new_value"}) if change.success
@@ -88,7 +88,7 @@ describe "Pending Changes", ->
it "sends the correct object to dataSubmitter", ->
pendingChanges.submit change
expect(resourcesMock.update.calls.length).toEqual 1
expect(resourcesMock.update.calls.count()).toBe 1
expect(resourcesMock.update).toHaveBeenCalledWith change
describe "successful request", ->
@@ -96,9 +96,9 @@ describe "Pending Changes", ->
change.success = true
it "calls remove with id and attribute name", ->
spyOn(pendingChanges, "remove").andCallFake(->)
spyOn(pendingChanges, "remove").and.callFake(->)
pendingChanges.submit change
expect(pendingChanges.remove.calls.length).toEqual 1
expect(pendingChanges.remove.calls.count()).toBe 1
expect(pendingChanges.remove).toHaveBeenCalledWith 1, "propertyName"
it "calls reset on the relevant scope", ->
@@ -114,7 +114,7 @@ describe "Pending Changes", ->
change.success = false
it "does not call remove", ->
spyOn(pendingChanges, "remove").andCallFake(->)
spyOn(pendingChanges, "remove").and.callFake(->)
pendingChanges.submit change
expect(pendingChanges.remove).not.toHaveBeenCalled()
@@ -128,13 +128,13 @@ describe "Pending Changes", ->
describe "cycling through all changes to submit to server", ->
it "sends the correct object to dataSubmitter", ->
spyOn(pendingChanges, "submit").andCallFake(->)
spyOn(pendingChanges, "submit").and.callFake(->)
pendingChanges.pendingChanges =
1: { "prop1": { attr: "prop1", value: 1 }, "prop2": { attr: "prop2", value: 2 } }
2: { "prop1": { attr: "prop1", value: 2 }, "prop2": { attr: "prop2", value: 4 } }
7: { "prop2": { attr: "prop2", value: 5 } }
pendingChanges.submitAll()
expect(pendingChanges.submit.calls.length).toEqual 5
expect(pendingChanges.submit.calls.count()).toBe 5
expect(pendingChanges.submit).toHaveBeenCalledWith { attr: "prop1", value: 1 }
expect(pendingChanges.submit).toHaveBeenCalledWith { attr: "prop2", value: 2 }
expect(pendingChanges.submit).toHaveBeenCalledWith { attr: "prop1", value: 2 }
@@ -142,7 +142,7 @@ describe "Pending Changes", ->
expect(pendingChanges.submit).toHaveBeenCalledWith { attr: "prop2", value: 5 }
it "returns an array of promises representing all sumbit requests", ->
spyOn(pendingChanges, "submit").andCallFake (change) -> change.value
spyOn(pendingChanges, "submit").and.callFake (change) -> change.value
pendingChanges.pendingChanges =
1: { "prop1": { attr: "prop1", value: 1 } }
2: { "prop1": { attr: "prop1", value: 2 }, "prop2": { attr: "prop1", value: 4 } }

View File

@@ -8,7 +8,7 @@ describe "switchClass service", ->
elementMock =
addClass: addClass
removeClass: removeClass
timeoutMock = jasmine.createSpy('timeout').andReturn "new timeout"
timeoutMock = jasmine.createSpy('timeout').and.returnValue "new timeout"
timeoutMock.cancel = jasmine.createSpy('timeout.cancel')
beforeEach ->
@@ -22,14 +22,14 @@ describe "switchClass service", ->
it "calls addClass on the element once", ->
switchClassService elementMock, "addClass", [], false
expect(addClass).toHaveBeenCalledWith "addClass"
expect(addClass.calls.length).toEqual 1
expect(addClass.calls.count()).toBe 1
it "calls removeClass on the element for ", ->
switchClassService elementMock, "", ["remClass1", "remClass2", "remClass3"], false
expect(removeClass).toHaveBeenCalledWith "remClass1"
expect(removeClass).toHaveBeenCalledWith "remClass2"
expect(removeClass).toHaveBeenCalledWith "remClass3"
expect(removeClass.calls.length).toEqual 3
expect(removeClass.calls.count()).toBe 3
it "call cancel on element.timout only if it exists", ->
switchClassService elementMock, "", [], false

View File

@@ -9,7 +9,7 @@ describe "Views service", ->
describe "setting views", ->
beforeEach ->
spyOn(Views, "selectView").andCallThrough()
spyOn(Views, "selectView").and.callThrough()
Views.setViews
view1: { name: 'View1', visible: true }
view2: { name: 'View2', visible: false }

View File

@@ -5,9 +5,10 @@ describe "LineItemsCtrl", ->
beforeEach ->
module "admin.lineItems"
this.addMatchers
toDeepEqual: (expected) ->
return angular.equals(this.actual, expected)
jasmine.addMatchers
toDeepEqual: (util, customEqualityTesters) ->
compare: (actual, expected) ->
{ pass: angular.equals(actual, expected) }
beforeEach inject(($controller, $rootScope, $httpBackend, _$timeout_, _VariantUnitManager_, _Enterprises_, _Orders_, _LineItems_, _OrderCycles_) ->
scope = $rootScope.$new()
@@ -19,9 +20,9 @@ describe "LineItemsCtrl", ->
LineItems = _LineItems_
OrderCycles = _OrderCycles_
VariantUnitManager = _VariantUnitManager_
spyOn(window, "daysFromToday").andReturn "SomeDate"
spyOn(window, "formatDate").andReturn "SomeDate"
spyOn(window, "parseDate").andReturn "SomeDate"
spyOn(window, "daysFromToday").and.returnValue "SomeDate"
spyOn(window, "formatDate").and.returnValue "SomeDate"
spyOn(window, "parseDate").and.returnValue "SomeDate"
supplier = { id: 1, name: "Supplier" }
distributor = { id: 5, name: "Distributor" }
@@ -51,7 +52,7 @@ describe "LineItemsCtrl", ->
expect(scope.quickSearch).toBeUndefined()
it "will not have reset the form state to pristine", ->
expect(scope.bulk_order_form.$setPristine.calls.length).toEqual 0
expect(scope.bulk_order_form.$setPristine.calls.count()).toBe 0
describe "after data is returned", ->
beforeEach ->
@@ -87,13 +88,13 @@ describe "LineItemsCtrl", ->
expect(scope.quickSearch).toBe = ""
it "resets the form state to pristine", ->
expect(scope.bulk_order_form.$setPristine.calls.length).toEqual 1
expect(scope.bulk_order_form.$setPristine.calls.count()).toBe 1
describe "deleting a line item", ->
order = line_item1 = line_item2 = null
beforeEach inject((LineItemResource) ->
spyOn(window,"confirm").andReturn true
spyOn(window,"confirm").and.returnValue true
order = { number: "R12345678" }
line_item1 = new LineItemResource({ id: 1, order: order })
line_item2 = new LineItemResource({ id: 2, order: order })
@@ -247,7 +248,7 @@ describe "LineItemsCtrl", ->
# A Units Variant is an API object which holds unit properies of a variant
beforeEach ->
spyOn(Math,"round").andCallThrough()
spyOn(Math,"round").and.callThrough()
it "returns '' if selectedUnitsVariant has no property 'variant_unit'", ->
expect(scope.formattedValueWithUnitName(1,{})).toEqual ''
@@ -267,14 +268,14 @@ describe "LineItemsCtrl", ->
it "calls Math.round with the quotient of scale and value, multiplied by 1000", ->
unitsVariant = { variant_unit: "weight" }
spyOn(VariantUnitManager, "getScale").andReturn 5
spyOn(VariantUnitManager, "getScale").and.returnValue 5
scope.formattedValueWithUnitName(10, unitsVariant)
expect(Math.round).toHaveBeenCalledWith 10/5 * 1000
it "returns the result of Math.round divided by 1000, followed by the result of getUnitName", ->
unitsVariant = { variant_unit: "weight" }
spyOn(VariantUnitManager, "getScale").andReturn 1000
spyOn(VariantUnitManager, "getUnitName").andReturn "kg"
spyOn(VariantUnitManager, "getScale").and.returnValue 1000
spyOn(VariantUnitManager, "getUnitName").and.returnValue "kg"
expect(scope.formattedValueWithUnitName(2000,unitsVariant)).toEqual "2 kg"
describe "updating the price upon updating the weight of a line item", ->

View File

@@ -4,9 +4,10 @@ describe "LineItems service", ->
beforeEach ->
module 'admin.lineItems'
this.addMatchers
toDeepEqual: (expected) ->
return angular.equals(this.actual, expected)
jasmine.addMatchers
toDeepEqual: (util, customEqualityTesters) ->
compare: (actual, expected) ->
{ pass: angular.equals(actual, expected) }
inject ($q, _$httpBackend_, _LineItems_, _LineItemResource_) ->
LineItems = _LineItems_
@@ -72,14 +73,14 @@ describe "LineItems service", ->
describe "#isSaved", ->
describe "when attributes of the object have been altered", ->
beforeEach ->
spyOn(LineItems, "diff").andReturn ["attr1", "attr2"]
spyOn(LineItems, "diff").and.returnValue ["attr1", "attr2"]
it "returns false", ->
expect(LineItems.isSaved({})).toBe false
describe "when attributes of the object have not been altered", ->
beforeEach ->
spyOn(LineItems, "diff").andReturn []
spyOn(LineItems, "diff").and.returnValue []
it "returns false", ->
expect(LineItems.isSaved({})).toBe true

View File

@@ -18,11 +18,11 @@ describe "AdminSimpleCreateOrderCycleCtrl", ->
addSupplier: jasmine.createSpy()
addDistributor: jasmine.createSpy()
setExchangeVariants: jasmine.createSpy()
new: jasmine.createSpy().andReturn order_cycle
new: jasmine.createSpy().and.returnValue order_cycle
Enterprise =
get: jasmine.createSpy().andReturn {id: 123}
get: jasmine.createSpy().and.returnValue {id: 123}
index: jasmine.createSpy()
suppliedVariants: jasmine.createSpy().andReturn('supplied variants')
suppliedVariants: jasmine.createSpy().and.returnValue('supplied variants')
EnterpriseFee =
index: jasmine.createSpy()
ocInstance = {}

View File

@@ -4,9 +4,10 @@ describe "OrderCycles service", ->
beforeEach ->
module 'admin.orderCycles'
this.addMatchers
toDeepEqual: (expected) ->
return angular.equals(this.actual, expected)
jasmine.addMatchers
toDeepEqual: (util, customEqualityTesters) ->
compare: (actual, expected) ->
{ pass: angular.equals(actual, expected) }
inject ($q, _$httpBackend_, _OrderCycles_, _OrderCycleResource_) ->
OrderCycles = _OrderCycles_
@@ -98,14 +99,14 @@ describe "OrderCycles service", ->
describe "#saved", ->
describe "when attributes of the object have been altered", ->
beforeEach ->
spyOn(OrderCycles, "diff").andReturn ["attr1", "attr2"]
spyOn(OrderCycles, "diff").and.returnValue ["attr1", "attr2"]
it "returns false", ->
expect(OrderCycles.saved({})).toBe false
describe "when attributes of the object have not been altered", ->
beforeEach ->
spyOn(OrderCycles, "diff").andReturn []
spyOn(OrderCycles, "diff").and.returnValue []
it "returns false", ->
expect(OrderCycles.saved({})).toBe true

View File

@@ -4,9 +4,10 @@ describe "Orders service", ->
beforeEach ->
module 'admin.orders'
this.addMatchers
toDeepEqual: (expected) ->
return angular.equals(this.actual, expected)
jasmine.addMatchers
toDeepEqual: (util, customEqualityTesters) ->
compare: (actual, expected) ->
{ pass: angular.equals(actual, expected) }
inject ($q, _$httpBackend_, _Orders_, _OrderResource_) ->
Orders = _Orders_
@@ -74,14 +75,14 @@ describe "Orders service", ->
describe "#saved", ->
describe "when attributes of the object have been altered", ->
beforeEach ->
spyOn(Orders, "diff").andReturn ["attr1", "attr2"]
spyOn(Orders, "diff").and.returnValue ["attr1", "attr2"]
it "returns false", ->
expect(Orders.saved({})).toBe false
describe "when attributes of the object have not been altered", ->
beforeEach ->
spyOn(Orders, "diff").andReturn []
spyOn(Orders, "diff").and.returnValue []
it "returns false", ->
expect(Orders.saved({})).toBe true

View File

@@ -15,26 +15,26 @@ describe "Option Value Namer", ->
it "when description is blank", ->
v.unit_description = null
spyOn(namer, "value_scaled").andReturn true
spyOn(namer, "option_value_value_unit").andReturn ["value", "unit"]
spyOn(namer, "value_scaled").and.returnValue true
spyOn(namer, "option_value_value_unit").and.returnValue ["value", "unit"]
expect(namer.name()).toBe "valueunit"
it "when description is present", ->
v.unit_description = 'desc'
spyOn(namer, "option_value_value_unit").andReturn ["value", "unit"]
spyOn(namer, "value_scaled").andReturn true
spyOn(namer, "option_value_value_unit").and.returnValue ["value", "unit"]
spyOn(namer, "value_scaled").and.returnValue true
expect(namer.name()).toBe "valueunit desc"
it "when value is blank and description is present", ->
v.unit_description = 'desc'
spyOn(namer, "option_value_value_unit").andReturn [null, null]
spyOn(namer, "value_scaled").andReturn true
spyOn(namer, "option_value_value_unit").and.returnValue [null, null]
spyOn(namer, "value_scaled").and.returnValue true
expect(namer.name()).toBe "desc"
it "spaces value and unit when value is unscaled", ->
v.unit_description = null
spyOn(namer, "option_value_value_unit").andReturn ["value", "unit"]
spyOn(namer, "value_scaled").andReturn false
spyOn(namer, "option_value_value_unit").and.returnValue ["value", "unit"]
spyOn(namer, "value_scaled").and.returnValue false
expect(namer.name()).toBe "value unit"
describe "determining if a variant's value is scaled", ->
@@ -44,7 +44,7 @@ describe "Option Value Namer", ->
p = {}
v = { product: p }
namer = new OptionValueNamer(v)
it "returns true when the product has a scale", ->
p.variant_unit_scale = 1000
expect(namer.value_scaled()).toBe true
@@ -120,4 +120,4 @@ describe "Option Value Namer", ->
p.variant_unit_scale = null
p.variant_unit_name = 'foo'
v.unit_value = null
expect(namer.option_value_value_unit()).toEqual [null, null]
expect(namer.option_value_value_unit()).toEqual [null, null]

View File

@@ -73,21 +73,21 @@ describe "SideMenu service", ->
describe "hiding an item by name", ->
it "sets visible to false on the response from find_by_name", ->
mockItem = { visible: true }
spyOn(SideMenu, 'find_by_name').andReturn mockItem
spyOn(SideMenu, 'find_by_name').and.returnValue mockItem
SideMenu.hide_item_by_name()
expect(mockItem.visible).toBe false
it "doesn't crash if null is returned from find_by_name", ->
spyOn(SideMenu, 'find_by_name').andReturn null
spyOn(SideMenu, 'find_by_name').and.returnValue null
SideMenu.hide_item_by_name()
describe "showing an item by name", ->
it "sets visible to false on the response from find_by_name", ->
mockItem = { visible: false }
spyOn(SideMenu, 'find_by_name').andReturn mockItem
spyOn(SideMenu, 'find_by_name').and.returnValue mockItem
SideMenu.show_item_by_name()
expect(mockItem.visible).toBe true
it "doesn't crash if null is returned from find_by_name", ->
spyOn(SideMenu, 'find_by_name').andReturn null
spyOn(SideMenu, 'find_by_name').and.returnValue null
SideMenu.show_item_by_name()

View File

@@ -47,7 +47,7 @@ describe "TagRulesCtrl", ->
beforeEach inject ($httpBackend) ->
rule = scope.tagGroups[0].rules[0]
spyOn(window, "confirm").andReturn(true)
spyOn(window, "confirm").and.returnValue(true)
$httpBackend.expectDELETE('/admin/enterprises/45/tag_rules/1.json').respond(status: 204)
scope.deleteTagRule(scope.tagGroups[0], rule)
$httpBackend.flush()