~caneypuggies/reformedchurcheslocator/couchapp-backbone

« back to all changes in this revision

Viewing changes to _attachments/js/vendor/backbone/test/model.coffee

  • Committer: Tim Black
  • Date: 2013-09-16 22:50:16 UTC
  • Revision ID: tim@alwaysreformed.com-20130916225016-zk8jiba25z33ew7h
Versioned Bower vendor directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Quick Backbone/CoffeeScript tests to make sure that inheritance
 
2
# works correctly.
 
3
 
 
4
{ok, equal, deepEqual}      = require 'assert'
 
5
{Model, Collection, Events} = require '../backbone'
 
6
 
 
7
 
 
8
# Patch `ok` to store a count of passed tests...
 
9
count = 0
 
10
oldOk = ok
 
11
ok = ->
 
12
  oldOk arguments...
 
13
  count++
 
14
 
 
15
 
 
16
class Document extends Model
 
17
 
 
18
  fullName: ->
 
19
    @get('name') + ' ' + @get('surname')
 
20
 
 
21
tempest = new Document
 
22
  id      : '1-the-tempest',
 
23
  title   : "The Tempest",
 
24
  name    : "William"
 
25
  surname : "Shakespeare"
 
26
  length  : 123
 
27
 
 
28
ok tempest.fullName() is "William Shakespeare"
 
29
ok tempest.get('length') is 123
 
30
 
 
31
 
 
32
class ProperDocument extends Document
 
33
 
 
34
  fullName: ->
 
35
    "Mr. " + super
 
36
 
 
37
properTempest = new ProperDocument tempest.attributes
 
38
 
 
39
ok properTempest.fullName() is "Mr. William Shakespeare"
 
40
ok properTempest.get('length') is 123
 
41
 
 
42
 
 
43
console.log "passed #{count} tests"