Fix failing JS specs

This commit is contained in:
Rohan Mitchell
2014-07-30 14:33:36 +10:00
parent 339e5975fa
commit 1ac5b79aeb
7 changed files with 16 additions and 13 deletions

View File

@@ -8,6 +8,7 @@
//= require angular-backstretch.js
//= require lodash.underscore.js
//= require angular-flash.min.js
//= require shared/mm-foundation-tpls-0.2.2.min.js
//= require moment
angular.module('templates', [])

View File

@@ -3,6 +3,7 @@ describe 'ProductsCtrl', ->
scope = null
event = null
Products = null
Cart = {}
beforeEach ->
module('Darkswarm')
@@ -15,7 +16,7 @@ describe 'ProductsCtrl', ->
inject ($controller) ->
scope = {}
ctrl = $controller 'ProductsCtrl', {$scope: scope, Products: Products, OrderCycle: OrderCycle}
ctrl = $controller 'ProductsCtrl', {$scope: scope, Products: Products, OrderCycle: OrderCycle, Cart: Cart}
it 'fetches products from Products', ->
expect(scope.Products.products).toEqual ['testy mctest']

View File

@@ -2,7 +2,7 @@ describe "filtering Groups", ->
filterGroups = null
groups = [{
name: "test"
long_description: "roger"
description: "roger"
enterprises: [{
name: "kittens"
}, {
@@ -10,7 +10,7 @@ describe "filtering Groups", ->
}]
}, {
name: "blankness"
long_description: "in the sky"
description: "in the sky"
enterprises: [{
name: "ponies"
}, {

View File

@@ -6,11 +6,8 @@ describe 'filtering urls', ->
inject ($filter) ->
filter = $filter('stripUrl')
it "removes http and www", ->
expect(filter("http://www.footle.com")).toEqual "footle.com"
it "removes http", ->
expect(filter("http://footle.com")).toEqual "footle.com"
it "removes https and www", ->
expect(filter("https://www.footle.com")).toEqual "footle.com"
it "removes just www", ->
expect(filter("www.footle.com")).toEqual "footle.com"
it "removes https", ->
expect(filter("https://www.footle.com")).toEqual "www.footle.com"

View File

@@ -55,6 +55,12 @@ describe 'Products service', ->
$httpBackend.flush()
expect(Cart.line_items[0].variant).toBe Products.products[0].variants[0]
it "sets primaryImageOrMissing when no images are provided", ->
$httpBackend.expectGET("/shop/products").respond([product])
$httpBackend.flush()
expect(Products.products[0].primaryImage).toBeUndefined()
expect(Products.products[0].primaryImageOrMissing).toEqual "/assets/noimage/small.png"
describe "determining the price to display for a product", ->
it "displays the product price when the product does not have variants", ->
$httpBackend.expectGET("/shop/products").respond([product])
@@ -66,4 +72,3 @@ describe 'Products service', ->
$httpBackend.expectGET("/shop/products").respond([product])
$httpBackend.flush()
expect(Products.products[0].price).toEqual 22