All files / src/model UserProfileInfo.ts

57.89% Statements 11/19
0% Branches 0/2
60% Functions 3/5
61.11% Lines 11/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 672x 2x   2x   2x   3x   3x   3x           1x           3x                                     3x         1x                                      
import { User } from './User';
import { StreamPost } from './StreamPost';
 
import { Util } from '../internal/Util';
 
export class UserProfileInfo {
  public static fromRest(data: any) {
    Util.assertHasProperties(data, 'user');
 
    const ret = new UserProfileInfo();
 
    ret.user = User.fromRest(data.user);
    if (!Util.isEmpty(data.recent_tweets)) {
      ret.recentStreamPosts = data.recent_tweets.map(tweet => StreamPost.fromRest(tweet));
    }
 
    if (!Util.isEmpty(data.comment)) {
      ret._comment = data.comment;
    }
    if (!Util.isEmpty(data.starred)) {
      ret._starred = data.starred;
    }
 
    return ret;
  }
 
  /**
   * A comment about the user
   * @hidden
   */
  private _comment: string;
 
  /**
   * Whether the user is starred
   * @hidden
   */
  public _starred: boolean;
 
  /** The user */
  public user: User;
 
  /** The user's recent posts */
  public recentStreamPosts: StreamPost[] = [];
 
  /** A comment about the user */
  public get comment() {
    if (this._comment !== undefined) {
      return this._comment;
    }
    if (this.user) {
      return this.user.comment;
    }
    return undefined;
  }
 
  /** Whether the user is starred */
  public get starred() {
    if (this._starred !== undefined) {
      return this._starred;
    }
    if (this.user && this.user.starred !== undefined) {
      return this.user.starred;
    }
    return false;
  }
}