Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
beforeEach(function () {
nfRegistryService = new NfRegistryService();
// setup the nfRegistryService
nfRegistryService.group = {identifier: 1, identity: 'Group 1', users: []};
nfRegistryService.users = [{identifier: 2, identity: 'User 1', checked: true}];
nfRegistryApi = new NfRegistryApi();
dialogService = new FdsDialogService();
snackBarService = new FdsSnackBarService();
dataTableService = new TdDataTableService();
comp = new NfRegistryAddUsersToGroup(nfRegistryApi, dataTableService, nfRegistryService, {
close: function () {
}
}, dialogService, snackBarService, {group: nfRegistryService.group});
// Spy
spyOn(nfRegistryApi, 'getUsers').and.callFake(function () {
}).and.returnValue(of([{identifier: 2, identity: 'User 1', checked: true}]));
spyOn(nfRegistryApi, 'updateUserGroup').and.callFake(function () {
}).and.returnValue(of({identifier: 1, identity: 'Group 1'}));
spyOn(comp.dialogRef, 'close');
spyOn(comp.snackBarService, 'openCoaster');
spyOn(comp, 'filterUsers').and.callThrough();
// initialize the component
comp.ngOnInit();
beforeEach(function () {
nfRegistryService = new NfRegistryService();
// setup the nfRegistryService
nfRegistryService.user = {identifier: 3, identity: 'User 3', userGroups: []};
nfRegistryService.groups = [{identifier: 1, identity: 'Group 1', configurable: true, checked: true, users: []}];
nfRegistryApi = new NfRegistryApi();
dialogService = new FdsDialogService();
snackBarService = new FdsSnackBarService();
dataTableService = new TdDataTableService();
comp = new NfRegistryAddUserToGroups(nfRegistryApi, dataTableService, nfRegistryService, {
close: function () {
}
}, dialogService, snackBarService, {user: nfRegistryService.user});
// Spy
spyOn(nfRegistryApi, 'getUserGroups').and.callFake(function () {
}).and.returnValue(of([{identifier: 1, identity: 'Group 1', configurable: true, checked: true, users: []}]));
spyOn(nfRegistryApi, 'getUserGroup').and.callFake(function () {
}).and.returnValue(of({identifier: 1, identity: 'Group 1'}));
spyOn(nfRegistryApi, 'updateUserGroup').and.callFake(function () {
}).and.returnValue(of({identifier: 1, identity: 'Group 1'}));
spyOn(comp.dialogRef, 'close');
spyOn(comp.snackBarService, 'openCoaster');
spyOn(comp, 'filterGroups').and.callThrough();