All files / src/testing-helpers/data.service-helpers data.service-helpers.hlpr.ts

86.36% Statements 19/22
100% Branches 0/0
71.43% Functions 5/7
90.48% Lines 19/21
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  1x   1x   1x   17x 17x 20x 20x   17x     1x   30x 30x 30x 30x 20x   30x         1x 17x       17x       17x    
import { TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs/Observable';
import { NgReduxTestingModule, MockNgRedux } from '@angular-redux/store/testing';
import { NameParsingService } from '../../app/services/data-service/name-parsing.service';
 
export const setupMockFormatService = () => {
  let mockFormatService;
  mockFormatService = jasmine.createSpyObj('mockFormatService', ['processContent', 'getBadgeColor', 'getCount']);
  mockFormatService.processContent.and.callFake(function(content, file) {
    file.content = content;
    return file;
  });
  return mockFormatService;
};
 
export const setupMockFileService = () => {
  let mockFileService;
  const filePrefixes: string[] = ['file'];
  const nameParsingService = new NameParsingService();
  mockFileService = jasmine.createSpyObj('mockFileService', ['getFileList', 'getFile']);
  mockFileService.getFile.and.callFake(function(url) {
    return Observable.of( new Response());
  });
  return mockFileService;
};
 
let resultFiles, numToDisplay;
 
export const setupMockPageActions = () => {
  const mockPageActions = jasmine.createSpyObj('mockPageActions',
    ['initializeListRequest', 'initializeListSuccess', 'initializeListFailed',
     'updateListRequest', 'updateListSuccess', 'updateListFailed', 'changeFile', 'refresh']
  );
  mockPageActions.initializeListSuccess.and.callFake((files, numDisplayed) => {
    resultFiles = files.map(file => file.name + '.html'); // pluck name from passed IFileInfos
    numToDisplay = numDisplayed;
  });
  return mockPageActions;
};