This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe 'CouchConnector' | |
describe 'loadDocument with mocked connection' | |
before | |
lastURL = '' | |
c = new connector.connector({ | |
port: 5984, | |
host: 'localhost', | |
user: '', | |
password: '', | |
database: 'test' | |
}) | |
c.connection = { | |
request: function(url) { | |
lastURL = url; | |
} | |
} | |
end | |
it 'should generate a restful URL based on a document id' | |
c.loadDocument('foobar') | |
lastURL.should.equal('/foobar') | |
end | |
it 'should generate a restful URL based on DB and Keys' | |
c.loadDocument({ | |
keys: ['name', 'age'], | |
type: 'person' | |
}) | |
lastURL.should.equal('/_view/person/by_name_age') | |
end | |
it 'should build a url with the get parameter descending' | |
c.loadDocument({ | |
keys: ['name', 'age'], | |
type: 'person', | |
descending: true | |
}) | |
lastURL.should.equal('/_view/person/by_name_age?descending=true') | |
end | |
it 'should build a URL with the get parameters descending and startkey' | |
c.loadDocument({ | |
keys: ['name', 'age'], | |
type: 'person', | |
descending: true, | |
startkey: ['john', '13'], | |
endkey: 'foo' | |
}) | |
lastURL.should.match('startkey=%5B%22john%22%2C%2213%22%5D') | |
lastURL.should.contain('descending=true') | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment