You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ro...@apache.org on 2015/10/22 16:23:39 UTC
[2/2] fauxton commit: updated refs/heads/master to 537853e
move tests into describe block
PR: #564
PR-URL: https://github.com/apache/couchdb-fauxton/pull/564
Reviewed-By: Benjamin Keen <be...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/1252d107
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/1252d107
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/1252d107
Branch: refs/heads/master
Commit: 1252d10712b502e6abd9eb332cdc436ba13ec547
Parents: b7dd66ce
Author: Robert Kowalski <ro...@apache.org>
Authored: Wed Oct 21 17:40:11 2015 +0200
Committer: Robert Kowalski <ro...@apache.org>
Committed: Thu Oct 22 16:23:29 2015 +0200
----------------------------------------------------------------------
.../tests/index-results.storesSpec.js | 182 +++++++++----------
1 file changed, 88 insertions(+), 94 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/1252d107/app/addons/documents/index-results/tests/index-results.storesSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/index-results/tests/index-results.storesSpec.js b/app/addons/documents/index-results/tests/index-results.storesSpec.js
index 85e1420..a3df44d 100644
--- a/app/addons/documents/index-results/tests/index-results.storesSpec.js
+++ b/app/addons/documents/index-results/tests/index-results.storesSpec.js
@@ -26,8 +26,9 @@ define([
beforeEach(function () {
store = new Stores.IndexResultsStore();
dispatchToken = FauxtonAPI.dispatcher.register(store.dispatch);
+ store.reset();
opts = {
- params: {},
+ params: {limit: 10, skip: 0},
database: {
safeID: function () { return '1';}
}
@@ -38,33 +39,103 @@ define([
FauxtonAPI.dispatcher.unregister(dispatchToken);
});
- describe('#hasResults', function () {
- it('returns true for collection', function () {
- store._collection = [1, 2, 3];
+ it('hasResults returns true for collection', function () {
+ store._collection = [1, 2, 3];
- assert.ok(store.hasResults());
- });
+ assert.ok(store.hasResults());
+ });
- it('returns false for empty collection', function () {
- store._collection = [];
+ it('hasResults returns false for empty collection', function () {
+ store._collection = [];
- assert.notOk(store.hasResults());
- });
+ assert.notOk(store.hasResults());
+ });
+ it('getResults has correct doc format', function () {
+ store._collection = new Documents.AllDocs([{_id: 'testId'}], opts);
+
+ var doc = store.getResults().results[0];
+ assert.equal(doc.id, 'testId');
+ assert.equal(doc.keylabel, 'id');
});
- describe('#getResults', function () {
+ it('tries to guess a pseudo schema for table views', function () {
+ var doclist = [
+ {_id: 'testId1', value: 'one'},
+ {_id: 'testId2', foo: 'one'},
+ {_id: 'testId3', bar: 'one'},
+ ];
- it('has correct doc format', function () {
- store._collection = new Documents.AllDocs([{_id: 'testId'}], opts);
+ var schema = store.getPseudoSchema(doclist);
- var doc = store.getResults().results[0];
- assert.equal(doc.id, 'testId');
- assert.equal(doc.keylabel, 'id');
- });
+ assert.ok(schema.indexOf('_id') !== -1);
+ assert.ok(schema.indexOf('value') !== -1);
+ assert.ok(schema.indexOf('foo') !== -1);
+ assert.ok(schema.indexOf('bar') !== -1);
+ });
+
+ it('uses unique values for the pseudo schema', function () {
+ var doclist = [
+ {_id: 'testId1', foo: 'one'},
+ {_id: 'testId2', foo: 'one'}
+ ];
+
+ var schema = store.getPseudoSchema(doclist);
+
+ assert.equal(schema.length, 2);
+ assert.equal(schema.length, 2);
+ assert.ok(schema.indexOf('foo') !== -1);
+ assert.ok(schema.indexOf('_id') !== -1);
+ });
+
+ it('puts the id into the array as first element', function () {
+ var doclist = [
+ {foo: 'one', _id: 'testId1'},
+ {foo: 'one', _id: 'testId2'}
+ ];
+
+ var schema = store.getPseudoSchema(doclist);
+
+ assert.equal(schema.shift(), '_id');
+ });
+
+ it('normalizes different content from include_docs enabled', function () {
+ var doclist = [
+ {_id: 'testId2', foo: 'one', doc: {"_rev": "1", "ente": "gans", "fuchs": "hase"}},
+ {_id: 'testId3', foo: 'two', doc: {"_rev": "2", "haus": "blau", "tanne": "acht"}}
+ ];
+
+ var res = store.normalizeTableData(doclist);
+ assert.deepEqual(res[0], {"_rev": "1", "ente": "gans", "fuchs": "hase"});
+ });
+
+ it('normalizes different content from include_docs disabled', function () {
+ var doclist = [
+ {id: 'testId2', foo: 'one'},
+ {id: 'testId3', foo: 'two'}
+ ];
+
+ var res = store.normalizeTableData(doclist);
+ assert.deepEqual(doclist, res);
+ });
+
+ it('finds out if we have at least one editable/deleteable doc which needs an id', function () {
+ var doclist = [
+ {id: 'testId2', foo: 'one'},
+ {id: 'testId3', foo: 'two'}
+ ];
+
+ assert.ok(store.getHasEditableAndDeletableDoc(doclist));
+ doclist = [
+ {foo: 'one'},
+ {foo: 'two'}
+ ];
+
+ assert.notOk(store.getHasEditableAndDeletableDoc(doclist));
});
+
});
describe('canSelectAll', function () {
@@ -207,83 +278,6 @@ define([
});
});
- it('tries to guess a pseudo schema for table views', function () {
- var doclist = [
- {_id: 'testId1', value: 'one'},
- {_id: 'testId2', foo: 'one'},
- {_id: 'testId3', bar: 'one'},
- ];
-
- var schema = store.getPseudoSchema(doclist);
-
- assert.ok(schema.indexOf('_id') !== -1);
- assert.ok(schema.indexOf('value') !== -1);
- assert.ok(schema.indexOf('foo') !== -1);
- assert.ok(schema.indexOf('bar') !== -1);
- });
-
- it('uses unique values for the pseudo schema', function () {
- var doclist = [
- {_id: 'testId1', foo: 'one'},
- {_id: 'testId2', foo: 'one'}
- ];
-
- var schema = store.getPseudoSchema(doclist);
-
- assert.equal(schema.length, 2);
- assert.equal(schema.length, 2);
- assert.ok(schema.indexOf('foo') !== -1);
- assert.ok(schema.indexOf('_id') !== -1);
- });
-
- it('puts the id into the array as first element', function () {
- var doclist = [
- {foo: 'one', _id: 'testId1'},
- {foo: 'one', _id: 'testId2'}
- ];
-
- var schema = store.getPseudoSchema(doclist);
-
- assert.equal(schema.shift(), '_id');
- });
-
- it('normalizes different content from include_docs enabled', function () {
- var doclist = [
- {_id: 'testId2', foo: 'one', doc: {"_rev": "1", "ente": "gans", "fuchs": "hase"}},
- {_id: 'testId3', foo: 'two', doc: {"_rev": "2", "haus": "blau", "tanne": "acht"}}
- ];
-
- var res = store.normalizeTableData(doclist);
- assert.deepEqual(res[0], {"_rev": "1", "ente": "gans", "fuchs": "hase"});
- });
-
- it('normalizes different content from include_docs disabled', function () {
- var doclist = [
- {id: 'testId2', foo: 'one'},
- {id: 'testId3', foo: 'two'}
- ];
-
- var res = store.normalizeTableData(doclist);
- assert.deepEqual(doclist, res);
- });
-
- it('finds out if we have at least one editable/deleteable doc which needs an id', function () {
- var doclist = [
- {id: 'testId2', foo: 'one'},
- {id: 'testId3', foo: 'two'}
- ];
-
- assert.ok(store.getHasEditableAndDeletableDoc(doclist));
-
- doclist = [
- {foo: 'one'},
- {foo: 'two'}
- ];
-
- assert.notOk(store.getHasEditableAndDeletableDoc(doclist));
- });
-
-
describe('#getMangoDoc', function () {
beforeEach(function () {
store = new Stores.IndexResultsStore();