nebulab-dropbox
Version:
Client library for the Dropbox API
96 lines (76 loc) • 3.64 kB
text/coffeescript
describe 'Dropbox.AccountInfo', ->
describe '.parse', ->
describe 'on the API example', ->
beforeEach ->
userData = {
"referral_link": "https://www.dropbox.com/referrals/r1a2n3d4m5s6t7",
"display_name": "John P. User",
"uid": 12345678,
"country": "US",
"quota_info": {
"shared": 253738410565,
"quota": 107374182400000,
"normal": 680031877871
},
"email": "johnpuser@company.com" # Added to reflect real responses.
}
= Dropbox.AccountInfo.parse userData
it 'parses name correctly', ->
expect().to.have.property 'name'
expect(.name).to.equal 'John P. User'
it 'parses email correctly', ->
expect().to.have.property 'email'
expect(.email).to.equal 'johnpuser@company.com'
it 'parses countryCode correctly', ->
expect().to.have.property 'countryCode'
expect(.countryCode).to.equal 'US'
it 'parses uid correctly', ->
expect().to.have.property 'uid'
expect(.uid).to.equal '12345678'
it 'parses referralUrl correctly', ->
expect().to.have.property 'referralUrl'
expect(.referralUrl).to.
equal 'https://www.dropbox.com/referrals/r1a2n3d4m5s6t7'
it 'parses quota correctly', ->
expect().to.have.property 'quota'
expect(.quota).to.equal 107374182400000
it 'parses usedQuota correctly', ->
expect().to.have.property 'usedQuota'
expect(.usedQuota).to.equal 933770288436
it 'parses privateBytes correctly', ->
expect().to.have.property 'privateBytes'
expect(.privateBytes).to.equal 680031877871
it 'parses sharedBytes correctly', ->
expect().to.have.property 'usedQuota'
expect(.sharedBytes).to.equal 253738410565
it 'parses publicAppUrl correctly', ->
expect(.publicAppUrl).to.equal null
it 'round-trips through json / parse correctly', ->
newInfo = Dropbox.AccountInfo.parse .json()
expect(newInfo).to.deep.equal
it 'passes null through', ->
expect(Dropbox.AccountInfo.parse(null)).to.equal null
it 'passes undefined through', ->
expect(Dropbox.AccountInfo.parse(undefined)).to.equal undefined
describe 'on real data from a "public app folder" application', ->
beforeEach ->
userData = {
"referral_link": "https://www.dropbox.com/referrals/NTM1OTg4MTA5",
"display_name": "Victor Costan",
"uid": 87654321, # Anonymized.
"public_app_url": "https://dl-web.dropbox.com/spa/90vw6zlu4268jh4/",
"country": "US",
"quota_info": {
"shared": 6074393565,
"quota": 73201090560,
"normal": 4684642723
},
"email": "spam@gmail.com" # Anonymized.
}
= Dropbox.AccountInfo.parse userData
it 'parses publicAppUrl correctly', ->
expect(.publicAppUrl).to.
equal 'https://dl-web.dropbox.com/spa/90vw6zlu4268jh4'
it 'round-trips through json / parse correctly', ->
newInfo = Dropbox.AccountInfo.parse .json()
expect(newInfo).to.deep.equal