blob: cc3a97069563e278b1f708f612781c63503681dc [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var NfRegistryRoutes = require('nifi-registry/nf-registry.routes.js');
var ngCoreTesting = require('@angular/core/testing');
var ngCommon = require('@angular/common');
var NfRegistry = require('nifi-registry/nf-registry.js');
var NfRegistryApi = require('nifi-registry/services/nf-registry.api.js');
var NfRegistryService = require('nifi-registry/services/nf-registry.service.js');
var NfPageNotFoundComponent = require('nifi-registry/components/page-not-found/nf-registry-page-not-found.js');
var NfRegistryExplorer = require('nifi-registry/components/explorer/nf-registry-explorer.js');
var NfRegistryAdministration = require('nifi-registry/components/administration/nf-registry-administration.js');
var NfRegistryUsersAdministration = require('nifi-registry/components/administration/users/nf-registry-users-administration.js');
var NfRegistryAddUser = require('nifi-registry/components/administration/users/dialogs/add-user/nf-registry-add-user.js');
var NfRegistryManageUser = require('nifi-registry/components/administration/users/sidenav/manage-user/nf-registry-manage-user.js');
var NfRegistryManageGroup = require('nifi-registry/components/administration/users/sidenav/manage-group/nf-registry-manage-group.js');
var NfRegistryManageBucket = require('nifi-registry/components/administration/workflow/sidenav/manage-bucket/nf-registry-manage-bucket.js');
var NfRegistryWorkflowAdministration = require('nifi-registry/components/administration/workflow/nf-registry-workflow-administration.js');
var NfRegistryGridListViewer = require('nifi-registry/components/explorer/grid-list/registry/nf-registry-grid-list-viewer.js');
var NfRegistryBucketGridListViewer = require('nifi-registry/components/explorer/grid-list/registry/nf-registry-bucket-grid-list-viewer.js');
var NfRegistryDropletGridListViewer = require('nifi-registry/components/explorer/grid-list/registry/nf-registry-droplet-grid-list-viewer.js');
var fdsCore = require('@flow-design-system/core');
var ngMoment = require('angular2-moment');
var ngCommonHttp = require('@angular/common/http');
var NfRegistryTokenInterceptor = require('nifi-registry/services/nf-registry.token.interceptor.js');
var NfStorage = require('nifi-registry/services/nf-storage.service.js');
var NfLoginComponent = require('nifi-registry/components/login/nf-registry-login.js');
var NfUserLoginComponent = require('nifi-registry/components/login/dialogs/nf-registry-user-login.js');
describe('NfRegistryExplorer Component', function () {
var comp;
var fixture;
var nfRegistryService;
beforeEach(function () {
ngCoreTesting.TestBed.configureTestingModule({
imports: [
ngMoment.MomentModule,
ngCommonHttp.HttpClientModule,
fdsCore,
NfRegistryRoutes
],
declarations: [
NfRegistry,
NfRegistryExplorer,
NfRegistryAdministration,
NfRegistryUsersAdministration,
NfRegistryManageUser,
NfRegistryManageGroup,
NfRegistryManageBucket,
NfRegistryAddUser,
NfRegistryWorkflowAdministration,
NfRegistryGridListViewer,
NfRegistryBucketGridListViewer,
NfRegistryDropletGridListViewer,
NfPageNotFoundComponent,
NfLoginComponent,
NfUserLoginComponent
],
providers: [
NfRegistryService,
NfRegistryApi,
NfStorage,
{
provide: ngCommonHttp.HTTP_INTERCEPTORS,
useClass: NfRegistryTokenInterceptor,
multi: true
},
{
provide: ngCommon.APP_BASE_HREF,
useValue: '/'
}
]
});
fixture = ngCoreTesting.TestBed.createComponent(NfRegistryExplorer);
// test instance
comp = fixture.componentInstance;
// from the root injector
nfRegistryService = ngCoreTesting.TestBed.get(NfRegistryService);
});
it('should have a defined component', function () {
fixture.detectChanges();
//assertions
expect(comp).toBeDefined();
expect(nfRegistryService.perspective).toBe('explorer');
});
it('should destroy the component', function () {
fixture.detectChanges();
// The function to test
comp.ngOnDestroy();
//assertions
expect(nfRegistryService.perspective).toBe('');
expect(nfRegistryService.buckets.length).toBe(0);
expect(nfRegistryService.droplet.identifier).toBeUndefined();
expect(nfRegistryService.bucket.identifier).toBeUndefined();
});
});