Code coverage report for api/comment/Comment.js

Statements: 53.33% (8 / 15)      Branches: 50% (1 / 2)      Functions: 25% (1 / 4)      Lines: 53.33% (8 / 15)      Ignored: none     

All files » api/comment/ » Comment.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 801                               1 7 7   7 7     1                                                                                                           1  
var FieldDBObject = require("./../FieldDBObject").FieldDBObject;
 
/**
 * @class Comments allow users to collaborate between each other and take
 *        note of important things, issues to be fixed, etc. These can
 *        appear on datum, sessions corpora, and datalists. Comments can
 *        also be edited and removed.
 *
 * @property {String} text Describe text here.
 * @property {Number} username Describe username here.
 * @property {Date} timestamp Describe timestamp here.
 *
 * @name  Comment
 * @extends FieldDBObject
 * @constructs
 */
var Comment = function Comment(options) {
  Eif (!this._fieldDBtype) {
    this._fieldDBtype = "Comment";
  }
  this.debug("Constructing Comment ", options);
  FieldDBObject.apply(this, arguments);
};
 
Comment.prototype = Object.create(FieldDBObject.prototype, /** @lends Comment.prototype */ {
 
  constructor: {
    value: Comment
  },
 
  build: {
    value: function(usermask) {
      this.timestamp = Date.now();
      this.gravatar = usermask.gravatar;
      this.username = usermask.username;
    }
  },
 
  /**
   * The edit function allows users to edit a comment.
   *
   * @param {String}  newtext Takes new text and replaces old one.
   */
  edit: {
    value: function(newtext) {
      this.text = newtext;
      this.timestampModified = Date.now();
    }
  },
 
  commentCreatedActivity: {
    value: function(indirectObjectString) {
      var commentstring = this.text;
      return [{
          verb: "commented",
          verbicon: "icon-comment",
          directobjecticon: "",
          directobject: "'" + commentstring + "'",
          indirectobject: indirectObjectString,
          teamOrPersonal: "team",
          context: " via Offline App."
        },
 
        {
          verb: "commented",
          verbicon: "icon-comment",
          directobjecticon: "",
          directobject: "'" + commentstring + "'",
          indirectobject: indirectObjectString,
          teamOrPersonal: "personal",
          context: " via Offline App."
        }
      ];
    }
  }
 
});
 
exports.Comment = Comment;