1
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
2
// use this file except in compliance with the License. You may obtain a copy of
5
// http://www.apache.org/licenses/LICENSE-2.0
7
// Unless required by applicable law or agreed to in writing, software
8
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
// License for the specific language governing permissions and limitations under
13
'modules/documents/resources',
15
], function (Models, testUtils) {
16
var assert = testUtils.assert;
18
describe('IndexCollection', function () {
20
beforeEach(function () {
21
collection = new Models.IndexCollection([{
29
database: {id: 'databaseId'},
30
design: '_design/myDoc'
35
it('Should return urlNext', function () {
36
var url = collection.urlNextPage(20);
38
assert.equal(url, 'database/databaseId/_design/myDoc/_view/?limit=20&reduce=false&startkey_docid=%22myId2%22&startkey=%22myId2%22');
42
it('Should return urlPrevious', function () {
43
var url = collection.urlPreviousPage(20, 'myId1');
45
assert.equal(url, 'database/databaseId/_design/myDoc/_view/?limit=20&reduce=false&startkey_docid=%22myId1%22&startkey=%22myId1%22');
51
describe('AllDocs', function () {
53
beforeEach(function () {
54
collection = new Models.AllDocs([{
62
database: {id: 'databaseId'},
68
it('Should return urlNext', function () {
69
var url = collection.urlNextPage(20);
71
assert.equal(url, 'database/databaseId/_all_docs?limit=21&startkey_docid=%22myId2%22&startkey=%22myId2%22');
75
it('Should return urlPrevious', function () {
76
var url = collection.urlPreviousPage(20, 'myId1');
77
assert.equal(url, 'database/databaseId/_all_docs?limit=20&startkey_docid=%22myId1%22&startkey=%22myId1%22');