I am currently utilizing angular, chai, angularmocks, mocha, and karma for testing. The test is displaying the following error:
Type error
map@[native code]
app/main.coffee:30:23 <- app/main.js:23:23
test/main.spec.coffee:59:20 <- test/main.spec.js:18:27
assert = chai.assert
expect = chai.expect
describe("The Address Book App", () ->
describe("the proper filter", () ->
proper = null
beforeEach( () ->
module("AddressBook")
inject( ($injector)->
proper = $injector.get("$filter")("proper")
)
)
it("should proper case a string", () ->
expect(proper("ned stark")).to.equal("Ned Stark")
)
)
)
main.coffee
class AddressBook
constructor: ->
return []
class Proper
uppercase: (word) ->
word[0].toUpperCase().concat(word.slice(1))
constructor: () ->
return (name) ->
words = name.toString().split(" ")
return words.map(@uppercase).join(" ")
angular.module('AddressBook', new AddressBook())
.filter('proper', [Proper])
Updated
Considering a class method 'uppercase' is more suitable for this scenario, and a slight modification in 'main.coffee' leads to a successful test.
class AddressBook
constructor: ->
return []
class Proper
@uppercase: (word) ->
word[0].toUpperCase().concat(word.slice(1))
constructor: () ->
return (name) ->
words = name.toString().split(" ")
return words.map(Proper.uppercase).join(" ")
angular.module('AddressBook', new AddressBook())
.filter('proper', [Proper])
However, if an instance method is truly required, how can the test be successfully passed?