Merging in master

This commit is contained in:
Rob H
2014-05-07 13:07:11 +10:00
212 changed files with 1265 additions and 9388 deletions

View File

@@ -0,0 +1,45 @@
describe 'filtering Hubs', ->
filter = null
filterHubs = null
hubs = [{
name: "frogs"
other: "roger"
address:
zipcode: "cats"
city: "cambridge"
state: "kansas"
}, {
name: "donkeys"
other: "roger"
address:
zipcode: ""
city: "Wellington"
state: "uzbekistan"
}]
beforeEach ->
module 'Darkswarm'
inject ($filter) ->
filter = $filter
filterHubs = $filter('hubs')
it 'has a hub filter', ->
expect(filter('hubs')).not.toBeNull()
it "filters by name", ->
expect(filterHubs(hubs, 'donkeys').length).toEqual 1
it "is case insensitive", ->
expect(filterHubs(hubs, 'DONKEYS').length).toEqual 1
it "filters by state", ->
expect(filterHubs(hubs, 'kansas').length).toEqual 1
it "filters by zipcode", ->
expect(filterHubs(hubs, 'cats').length).toEqual 1
it "gives all hubs when no argument is specified", ->
expect(filterHubs(hubs, '').length).toEqual 2
it "does not filter by anything else", ->
expect(filterHubs(hubs, 'roger').length).toEqual 0

View File

@@ -0,0 +1,28 @@
describe 'filtering producers', ->
filter = null
filterProducers = null
producers = [{
name: "frogs"
other: "roger"
address:
zipcode: "cats"
city: "cambridge"
state: "kansas"
}, {
name: "donkeys"
other: "roger"
address:
zipcode: ""
city: "Wellington"
state: "uzbekistan"
}]
beforeEach ->
module 'Darkswarm'
inject ($filter) ->
filter = $filter
filterProducers = $filter('filterProducers')
it 'has a producer filter', ->
expect(filter('filterProducers')).not.toBeNull()

View File

@@ -9,8 +9,3 @@ describe 'Navigation service', ->
it "caches the path provided", ->
Navigation.navigate "/foo"
expect(Navigation.path).toEqual "/foo"
it "defaults to the first path in the list", ->
Navigation.paths = ["/test", "/bar"]
Navigation.navigate()
expect(Navigation.path).toEqual "/test"

View File

@@ -58,18 +58,18 @@ describe 'Order service', ->
expect(Order.paymentMethod()).toEqual {test: "foo"}
it "Posts the Order to the server", ->
$httpBackend.expectPUT("/shop/checkout", {order: Order.preprocess()}).respond 200, {path: "test"}
$httpBackend.expectPUT("/checkout", {order: Order.preprocess()}).respond 200, {path: "test"}
Order.submit()
$httpBackend.flush()
it "sends flash messages to the flash service", ->
$httpBackend.expectPUT("/shop/checkout").respond 400, {flash: {error: "frogs"}}
$httpBackend.expectPUT("/checkout").respond 400, {flash: {error: "frogs"}}
Order.submit()
$httpBackend.flush()
expect(flash.error).toEqual "frogs"
it "puts errors into the scope", ->
$httpBackend.expectPUT("/shop/checkout").respond 400, {errors: {error: "frogs"}}
$httpBackend.expectPUT("/checkout").respond 400, {errors: {error: "frogs"}}
Order.submit()
$httpBackend.flush()
expect(Order.errors).toEqual {error: "frogs"}