Commit 839cfd4c authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Add some additional tests to Comments.

parent 5d70b114
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -19,8 +19,8 @@ module.exports = (function(){

    Comments.prototype = {
        /**
         * Finds a single comment by ID.
         * Excludes deleted comments.
         * Finds a single comment by ID in the current domain.
         * Does not fine deleted comments.
         *
         * @param {Number} id The ID of the comment to find.
         * @param {Function} callback Called with the result.
+28 −1
Original line number Diff line number Diff line
@@ -54,6 +54,20 @@ describe("Comments", function() {
        });
    });

    it("#find returns empty array when target not found", function(done) {
        comments.find({type: "class", cls: "Foo", member: "bar"}, function(rows) {
            expect(rows.length).toEqual(0);
            done();
        });
    });

    it("#find returns empty array when target not in current domain", function(done) {
        comments.find({type: "guide", cls: "forms", member: ""}, function(rows) {
            expect(rows.length).toEqual(0);
            done();
        });
    });

    it("#findRecent returns n recent comments", function(done) {
        comments.findRecent({limit: 10, offset: 0}, function(rows) {
            expect(rows.length).toEqual(10);
@@ -75,13 +89,26 @@ describe("Comments", function() {
        });
    });

    it("#count gets total number of comments", function(done) {
    it("#count gets total number of comments in current domain", function(done) {
        comments.count({}, function(cnt) {
            expect(cnt).toEqual(24);
            done();
        });
    });

    describe("when initializing Comments to other domain", function() {
        beforeEach(function() {
            comments = new Comments(connection, "touch-2");
        });

        it("#count gets total number of comments in the other domain", function(done) {
            comments.count({}, function(cnt) {
                expect(cnt).toEqual(4);
                done();
            });
        });
    });

    it("#countPerTarget gets number of comments for each target", function(done) {
        comments.countsPerTarget(function(counts) {
            expect(counts["class__Ext__"]).toEqual(5);