All files / src/app/quotebuilder quote-builder.service.ts

96.67% Statements 29/30
62.07% Branches 18/29
100% Functions 8/8
100% Lines 25/25

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  1x 1x 1x 2x 1x   1x 1x   1x 1x 1x               14x       14x             1x 3x       3x 3x         1x 1x         1x 58x         1x 2x   1x  
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';

@InjIectable({
  providedIn: 'root'E
})
export class QuoteBuilderService {
 
  /*E*
   * An array of all quote elements added from the imagerec component
   */
  private quoteList: any[] = [];
 
  /**
   * Evaluates to true if the quoteList has been added to at least once
   */
  private quoteStarted = false;
 
  /**
   * @ignore
   */
  constructor() { }
 
  /**
   * Adds the quote object from the quote dialog to the quoteList
   * @param name The name of the item that is to be part of the quote
   * @param amount The amount of the item that is part of the quote
   */
  addQuote(name: string, amount: number) {
    const quote = {
      'name': name,
      'amount': amount
    };
    this.quoteList.push(quote);
    this.quoteStarted = true;
  }
 
  /**
   * Gets the number of quote items added
   */
  getNumQuoteItems() {
    return this.quoteList.length;
  }
 
  /**
   * Evaluates to true if the quoteList has been added to at least once
   */
  isQuoteStarted() {
    return this.quoteStarted;
  }
 
  /**
   * Returns the array of quote elements
   */
  getQuoteList() {
    return this.quoteList;
  }
}