summaryrefslogtreecommitdiff
path: root/spec/javascripts/models/session_spec.js.coffee
blob: 581b3de49ef22db3f5bb8967c6764284763d1cb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
describe "csx.Models.Session", ->
  subject = null

  beforeEach ->
    subject = new csx.Models.Session()

  it "is invalid, when the email is missing", ->
    expectedError = "Email can't be blank"

    expect(subject.isValid()).toEqual(false)
    expect(subject.validationError['email']).toEqual(expectedError)

  it "is invalid, when the email is not a valid email addrees", ->
    subject.set('email', 'blah')
    expectedError = "Email is invalid"

    expect(subject.isValid()).toEqual(false)
    expect(subject.validationError['email']).toEqual(expectedError)

  it "is invalid, when the password is missing", ->
    expectedError = "Password can't be blank"

    expect(subject.isValid()).toEqual(false)
    expect(subject.validationError['password']).toEqual(expectedError)

  it "is valid", ->
    subject.set('email', 'test@example.com')
    subject.set('password', 'password')
    expect(subject.isValid()).toEqual(true)
    expect(subject.validationError).toEqual(null)