blob: 7091d0fb1499551c34222f26ada877a76f0e81b0 [file] [log] [blame]
Stone, Avi (as206k)548c5a22018-06-03 13:12:12 +03001// import {APP_BASE_HREF} from '@angular/common'; import {ComponentFixture,
2// TestBed, async} from '@angular/core/testing'; import {FormsModule} from
3// '@angular/forms'; import {BaseRequestOptions, Http, HttpModule, XHRBackend}
4// from '@angular/http'; import {MockBackend} from '@angular/http/testing';
5// import {ActivatedRoute} from '@angular/router'; import {NgSelectModule} from
6// '@ng-select/ng-select'; import {sortBy} from 'lodash'; import {ToastrModule,
7// ToastrService} from 'ngx-toastr'; import {FeatherIconsPipe} from
8// '../api/feather-pipe'; import {RestApiService} from
9// '../api/rest-api.service'; import {DiagramComponent} from
10// '../diagram/diagram.component'; import {Store} from '../store/store'; import
11// {GeneralComponent, groupingData} from './general.component'; const data = [
12// { name: 'avi', version: '2.0' }, { name: 'stone', version:
13// '0.9' }, { name: 'avi', version: '2.1' }, { name: 'vosk',
14// version: '0.1' }, { name: 'liav', version: '0.5' } ]; const
15// sortedMatchVfcmtList = ['avi', 'liav', 'stone', 'vosk']; const
16// sortedVersionInGroup = [ { name: 'avi', version: '2.1' }, {
17// name: 'avi', version: '2.0' } ]; class MockActivatedRoute { snapshot
18// = { params: { contextType: 'SERVICES ', uuid:
19// 'b6f8fec0-6bf9-4c32-a3c3-1d440411862e', version: '0.1', mcid:
20// 'new' }, routeConfig: { children: { filter: () => {}
21// } } }; } describe('GeneralComponent', () => { let component :
22// GeneralComponent; let fixture : ComponentFixture < GeneralComponent >;
23// let backend : MockBackend; beforeEach(async(() => {
24// TestBed.configureTestingModule({ imports: [ FormsModule,
25// NgSelectModule, HttpModule, ToastrModule.forRoot() ],
26// declarations: [ GeneralComponent, FeatherIconsPipe, DiagramComponent
27// ], providers: [ RestApiService, Store,
28// ToastrService, { provide: ActivatedRoute, useClass:
29// MockActivatedRoute }, { provide: APP_BASE_HREF,
30// useValue: '/' }, MockBackend, BaseRequestOptions, {
31// provide: Http, deps: [ MockBackend,
32// BaseRequestOptions ], useFactory: (backend : XHRBackend,
33// defaultOptions : BaseRequestOptions) => { return new
34// Http(backend, defaultOptions); } } ]
35// }).compileComponents(); backend = TestBed.get(MockBackend); }));
36// it('should sort vfcmt by A to Z', () => { const sorted =
37// groupingData(data); const vfcmtList = sortBy(Object.keys(sorted), name =>
38// name); expect(vfcmtList).toEqual(sortedMatchVfcmtList); });
39// it('should group vfcmt by name', () => { const sorted =
40// groupingData(data); expect(Object.keys(sorted)).toEqual(['avi', 'stone',
41// 'vosk', 'liav']); }); it('should version array be sorted in group', () =>
42// { const sorted = groupingData(data);
43// expect(Object.values(sorted)[0]).toEqual(sortedVersionInGroup); }); });