ares-ide
Version:
A browser-based code editor and UI designer for Enyo 2 projects
93 lines (73 loc) • 3.31 kB
text/coffeescript
describe 'Dropbox.PublicUrl', ->
describe '.parse', ->
describe 'on the /shares API example', ->
beforeEach ->
urlData = {
"url": "http://db.tt/APqhX1",
"expires": "Tue, 01 Jan 2030 00:00:00 +0000"
}
= Dropbox.PublicUrl.parse urlData, false
it 'parses url correctly', ->
expect().to.have.property 'url'
expect(.url).to.equal 'http://db.tt/APqhX1'
it 'parses expiresAt correctly', ->
expect().to.have.property 'expiresAt'
expect(.expiresAt).to.be.instanceOf Date
expect([
'Tue, 01 Jan 2030 00:00:00 GMT', # every sane JS platform
'Tue, 1 Jan 2030 00:00:00 UTC' # Internet Explorer
]).to.contain(.expiresAt.toUTCString())
it 'parses isDirect correctly', ->
expect().to.have.property 'isDirect'
expect(.isDirect).to.equal false
it 'parses isPreview correctly', ->
expect().to.have.property 'isPreview'
expect(.isPreview).to.equal true
it 'round-trips through json / parse correctly', ->
newUrl = Dropbox.PublicUrl.parse .json()
newUrl.json() # Get _json populated for newUrl.
expect(newUrl).to.deep.equal
it 'passes null through', ->
expect(Dropbox.PublicUrl.parse(null)).to.equal null
it 'passes undefined through', ->
expect(Dropbox.PublicUrl.parse(undefined)).to.equal undefined
describe 'Dropbox.CopyReference', ->
describe '.parse', ->
describe 'on the API example', ->
beforeEach ->
refData = {
"copy_ref": "z1X6ATl6aWtzOGq0c3g5Ng",
"expires": "Fri, 31 Jan 2042 21:01:05 +0000"
}
= Dropbox.CopyReference.parse refData
it 'parses tag correctly', ->
expect().to.have.property 'tag'
expect(.tag).to.equal 'z1X6ATl6aWtzOGq0c3g5Ng'
it 'parses expiresAt correctly', ->
expect().to.have.property 'expiresAt'
expect(.expiresAt).to.be.instanceOf Date
expect([
'Fri, 31 Jan 2042 21:01:05 GMT', # every sane JS platform
'Fri, 31 Jan 2042 21:01:05 UTC' # Internet Explorer
]).to.contain(.expiresAt.toUTCString())
it 'round-trips through json / parse correctly', ->
newRef = Dropbox.CopyReference.parse .json()
expect(newRef).to.deep.equal
describe 'on a reference string', ->
beforeEach ->
rawRef = 'z1X6ATl6aWtzOGq0c3g5Ng'
= Dropbox.CopyReference.parse rawRef
it 'parses tag correctly', ->
expect().to.have.property 'tag'
expect(.tag).to.equal 'z1X6ATl6aWtzOGq0c3g5Ng'
it 'parses expiresAt correctly', ->
expect().to.have.property 'expiresAt'
expect(.expiresAt).to.be.instanceOf Date
expect(.expiresAt - (new Date())).to.be.below 1000
it 'round-trips through json / parse correctly', ->
newRef = Dropbox.CopyReference.parse .json()
expect(newRef).to.deep.equal
it 'passes null through', ->
expect(Dropbox.CopyReference.parse(null)).to.equal null
it 'passes undefined through', ->
expect(Dropbox.CopyReference.parse(undefined)).to.equal undefined