describe('RgwUserFormComponent', () => {
let component: RgwUserFormComponent;
let fixture: ComponentFixture<RgwUserFormComponent>;
+ let rgwUserService: RgwUserService;
+ let formHelper: FormHelper;
configureTestBed({
declarations: [RgwUserFormComponent],
fixture = TestBed.createComponent(RgwUserFormComponent);
component = fixture.componentInstance;
fixture.detectChanges();
+ rgwUserService = TestBed.get(RgwUserService);
+ formHelper = new FormHelper(component.userForm);
});
it('should create', () => {
});
describe('s3 key management', () => {
- let rgwUserService: RgwUserService;
-
beforeEach(() => {
- rgwUserService = TestBed.get(RgwUserService);
spyOn(rgwUserService, 'addS3Key').and.stub();
});
});
describe('username validation', () => {
- let rgwUserService: RgwUserService;
- let formHelper: FormHelper;
-
beforeEach(() => {
- rgwUserService = TestBed.get(RgwUserService);
spyOn(rgwUserService, 'enumerate').and.returnValue(observableOf(['abc', 'xyz']));
- formHelper = new FormHelper(component.userForm);
});
it('should validate that username is required', () => {
})
);
});
+
+ describe('onSubmit', () => {
+ it('should be able to clear the mail field on update', () => {
+ spyOn(rgwUserService, 'update');
+ component.editing = true;
+ formHelper.setValue('email', '', true);
+ component.onSubmit();
+ expect(rgwUserService.update).toHaveBeenCalledWith(null, {
+ display_name: null,
+ email: '',
+ max_buckets: 1000,
+ suspended: false
+ });
+ });
+ });
});