mirror of
https://github.com/fazo96/homework.git
synced 2025-01-26 14:44:20 +01:00
added some jasmine tests
This commit is contained in:
parent
50fff6b5e9
commit
6d31b3d1ff
@ -15,4 +15,6 @@ spiderable
|
|||||||
kevohagan:sweetalert
|
kevohagan:sweetalert
|
||||||
accounts-twitter
|
accounts-twitter
|
||||||
fazo96:paginator
|
fazo96:paginator
|
||||||
|
sanjo:jasmine
|
||||||
|
velocity:html-reporter
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ accounts-base@1.1.2
|
|||||||
accounts-oauth@1.1.2
|
accounts-oauth@1.1.2
|
||||||
accounts-password@1.0.4
|
accounts-password@1.0.4
|
||||||
accounts-twitter@1.0.2
|
accounts-twitter@1.0.2
|
||||||
|
alanning:package-stubber@0.0.9
|
||||||
|
amplify@1.0.0
|
||||||
application-configuration@1.0.3
|
application-configuration@1.0.3
|
||||||
autoupdate@1.1.3
|
autoupdate@1.1.3
|
||||||
base64@1.0.1
|
base64@1.0.1
|
||||||
@ -38,6 +40,7 @@ jquery@1.0.1
|
|||||||
json@1.0.1
|
json@1.0.1
|
||||||
kevohagan:sweetalert@0.3.1
|
kevohagan:sweetalert@0.3.1
|
||||||
launch-screen@1.0.0
|
launch-screen@1.0.0
|
||||||
|
less@1.0.11
|
||||||
livedata@1.0.11
|
livedata@1.0.11
|
||||||
localstorage@1.0.1
|
localstorage@1.0.1
|
||||||
logging@1.0.5
|
logging@1.0.5
|
||||||
@ -61,6 +64,11 @@ reactive-var@1.0.3
|
|||||||
reload@1.1.1
|
reload@1.1.1
|
||||||
retry@1.0.1
|
retry@1.0.1
|
||||||
routepolicy@1.0.2
|
routepolicy@1.0.2
|
||||||
|
sanjo:jasmine@0.6.4
|
||||||
|
sanjo:karma-chrome-launcher@0.1.5_1
|
||||||
|
sanjo:karma-coffee-preprocessor@0.2.1
|
||||||
|
sanjo:karma-jasmine@0.2.3
|
||||||
|
sanjo:karma@0.12.24_2
|
||||||
service-configuration@1.0.2
|
service-configuration@1.0.2
|
||||||
session@1.0.4
|
session@1.0.4
|
||||||
sha@1.0.1
|
sha@1.0.1
|
||||||
@ -75,5 +83,9 @@ twitter@1.1.2
|
|||||||
ui@1.0.4
|
ui@1.0.4
|
||||||
underscore@1.0.1
|
underscore@1.0.1
|
||||||
url@1.0.2
|
url@1.0.2
|
||||||
|
velocity:core@1.0.0-rc.5
|
||||||
|
velocity:html-reporter@0.3.0
|
||||||
|
velocity:meteor-stubs@1.0.0_2
|
||||||
|
velocity:shim@0.0.2
|
||||||
webapp-hashing@1.0.1
|
webapp-hashing@1.0.1
|
||||||
webapp@1.1.4
|
webapp@1.1.4
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
# Homework - Server Side
|
# Homework - Server Side
|
||||||
notes = share.notes
|
notes = share.notes
|
||||||
console.log "Started Homework server!"
|
|
||||||
if process.env.MAIL_URL
|
|
||||||
console.log "Sending emails using "+process.env.MAIL_URL
|
|
||||||
else
|
|
||||||
console.log "Not Sending Emails, please set the MAIL_URL environment variable"
|
|
||||||
|
|
||||||
notes = new Meteor.Collection "notes"
|
notes = new Meteor.Collection "notes"
|
||||||
getUser = (id) -> Meteor.users.findOne { _id: id }
|
getUser = (id) -> Meteor.users.findOne { _id: id }
|
||||||
|
36
tests/jasmine/client/unit/clienttests.coffee
Normal file
36
tests/jasmine/client/unit/clienttests.coffee
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
###
|
||||||
|
describe 'user creation', ->
|
||||||
|
it 'requires a valid email and a password', (done) ->
|
||||||
|
Accounts.createUser {
|
||||||
|
email: 'a@b.com',
|
||||||
|
password: 'somepassword'
|
||||||
|
}, (err) -> expect(err).toBeUndefined(); done()
|
||||||
|
|
||||||
|
it "doesn't work without a password", ->
|
||||||
|
id = Accounts.createUser {
|
||||||
|
email: 'a@b.c'
|
||||||
|
}
|
||||||
|
expect(id).toBeUndefined()
|
||||||
|
|
||||||
|
it "doesn't work with an invalid email", ->
|
||||||
|
id = Accounts.createUser {
|
||||||
|
email: 'abbbbb.c',
|
||||||
|
password: 'somepassword'
|
||||||
|
}
|
||||||
|
expect(id).toBeUndefined()
|
||||||
|
|
||||||
|
it "adds the user's date format if it's not specified", ->
|
||||||
|
id = Accounts.createUser {
|
||||||
|
email: 'a@b.c',
|
||||||
|
password: 'somepassword'
|
||||||
|
}
|
||||||
|
expect(Meteor.users.findOne(id).dateformat).toBe(jasmine.any('String'))
|
||||||
|
|
||||||
|
it "records the user's date format", ->
|
||||||
|
id = Accounts.createUser {
|
||||||
|
email: 'a@b.c',
|
||||||
|
password: 'somepassword'
|
||||||
|
dateformat: 'DD/MM/YYYY'
|
||||||
|
}
|
||||||
|
expect(Meteor.users.findOne(id).dateformat).toBe('DD/MM/YYYY')
|
||||||
|
###
|
11015
tests/jasmine/server/unit/package-stubs.js
Normal file
11015
tests/jasmine/server/unit/package-stubs.js
Normal file
File diff suppressed because one or more lines are too long
11050
tests/jasmine/server/unit/packageMocksSpec.js
Normal file
11050
tests/jasmine/server/unit/packageMocksSpec.js
Normal file
File diff suppressed because one or more lines are too long
20
tests/jasmine/server/unit/servertests.coffee
Normal file
20
tests/jasmine/server/unit/servertests.coffee
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
describe 'validateEmail', ->
|
||||||
|
it 'accepts valid email addresses', ->
|
||||||
|
['a@b.com','test@you.me'].forEach (e) ->
|
||||||
|
expect(validateEmail(e)).toBe(true)
|
||||||
|
|
||||||
|
it 'refuses invalid email addresses', ->
|
||||||
|
['ciao','test','@@.eee','...@','a@b.c'].forEach (e) ->
|
||||||
|
expect(validateEmail(e)).toBe(false)
|
||||||
|
|
||||||
|
describe 'userValidated', ->
|
||||||
|
it 'does not crash with null parameters', ->
|
||||||
|
expect(userValidated()).toBe(false)
|
||||||
|
it 'treats twitter users as valid', ->
|
||||||
|
user = { services: twitter: {}}
|
||||||
|
expect(userValidated(user)).toBe(true)
|
||||||
|
it 'treats email users as valid only if they verified their email', ->
|
||||||
|
user = { services: {}, emails: [ {address: 'a@b.com', verified: false} ] }
|
||||||
|
expect(userValidated(user)).toBe(false)
|
||||||
|
user.emails[0].verified = true
|
||||||
|
expect(userValidated(user)).toBe(true)
|
Loading…
Reference in New Issue
Block a user