mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-5422] remove deprecated "async()" from unit tests (#7109)
* remove angualar async from content services * upgrade more tests * upgrade core tests * upgrade tests * fix deprecated constant * fix tests * fix after rebase
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { MatCheckbox, MatCheckboxChange } from '@angular/material/checkbox';
|
||||
import { setupTestBed } from '../../../testing/setup-test-bed';
|
||||
@@ -68,7 +68,7 @@ describe('CardViewBoolItemComponent', () => {
|
||||
expect(value).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should NOT render the label and value if the property is NOT editable and doesn\'t have a proper boolean value set', () => {
|
||||
it('should NOT render the label and value if the property is NOT editable and has no proper boolean value set', () => {
|
||||
component.editable = true;
|
||||
component.property.value = undefined;
|
||||
component.property.editable = false;
|
||||
@@ -189,15 +189,16 @@ describe('CardViewBoolItemComponent', () => {
|
||||
expect(cardViewUpdateService.update).toHaveBeenCalledWith(property, true);
|
||||
});
|
||||
|
||||
it('should update the property value after a changed', async(() => {
|
||||
it('should update the property value after a changed', async () => {
|
||||
component.property.value = true;
|
||||
|
||||
component.changed(<MatCheckboxChange> { checked: false });
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(component.property.value).toBe(false);
|
||||
});
|
||||
}));
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(component.property.value).toBe(false);
|
||||
});
|
||||
|
||||
it('should trigger an update event on the CardViewUpdateService [integration]', (done) => {
|
||||
const cardViewUpdateService = TestBed.inject(CardViewUpdateService);
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { setupTestBed } from '../../../testing/setup-test-bed';
|
||||
import moment from 'moment-es6';
|
||||
@@ -209,7 +209,7 @@ describe('CardViewDateItemComponent', () => {
|
||||
component.onDateChanged({ value: expectedDate });
|
||||
});
|
||||
|
||||
it('should update the property value after a successful update attempt', async(() => {
|
||||
it('should update the property value after a successful update attempt', fakeAsync(() => {
|
||||
component.editable = true;
|
||||
component.property.editable = true;
|
||||
component.property.value = null;
|
||||
@@ -271,7 +271,7 @@ describe('CardViewDateItemComponent', () => {
|
||||
expect(datePickerClearToggle).toBeNull('Clean Icon should not be in DOM');
|
||||
});
|
||||
|
||||
it('should remove the property value after a successful clear attempt', async(() => {
|
||||
it('should remove the property value after a successful clear attempt', fakeAsync(() => {
|
||||
component.editable = true;
|
||||
component.property.editable = true;
|
||||
component.property.value = 'Jul 10 2017';
|
||||
@@ -286,7 +286,7 @@ describe('CardViewDateItemComponent', () => {
|
||||
);
|
||||
}));
|
||||
|
||||
it('should remove the property default value after a successful clear attempt', async(() => {
|
||||
it('should remove the property default value after a successful clear attempt', fakeAsync(() => {
|
||||
component.editable = true;
|
||||
component.property.editable = true;
|
||||
component.property.default = 'Jul 10 2017';
|
||||
@@ -301,7 +301,7 @@ describe('CardViewDateItemComponent', () => {
|
||||
);
|
||||
}));
|
||||
|
||||
it('should remove actual and default value after a successful clear attempt', async(() => {
|
||||
it('should remove actual and default value after a successful clear attempt', fakeAsync(() => {
|
||||
component.editable = true;
|
||||
component.property.editable = true;
|
||||
component.property.default = 'Jul 10 2017';
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed, fakeAsync } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { CardViewKeyValuePairsItemModel } from '../../models/card-view-keyvaluepairs.model';
|
||||
import { CardViewKeyValuePairsItemComponent } from './card-view-keyvaluepairsitem.component';
|
||||
@@ -28,7 +28,7 @@ describe('CardViewKeyValuePairsItemComponent', () => {
|
||||
|
||||
let fixture: ComponentFixture<CardViewKeyValuePairsItemComponent>;
|
||||
let component: CardViewKeyValuePairsItemComponent;
|
||||
let cardViewUpdateService;
|
||||
let cardViewUpdateService: CardViewUpdateService;
|
||||
const mockEmptyData = [{ name: '', value: '' }];
|
||||
const mockData = [{ name: 'test-name', value: 'test-value' }];
|
||||
|
||||
@@ -125,7 +125,7 @@ describe('CardViewKeyValuePairsItemComponent', () => {
|
||||
expect(component.property.value.length).toBe(0);
|
||||
});
|
||||
|
||||
it('should update property on input blur', async(() => {
|
||||
it('should update property on input blur', fakeAsync(() => {
|
||||
spyOn(cardViewUpdateService, 'update');
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
@@ -153,7 +153,7 @@ describe('CardViewKeyValuePairsItemComponent', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not update property if at least one input is empty on blur', async(() => {
|
||||
it('should not update property if at least one input is empty on blur', fakeAsync(() => {
|
||||
spyOn(cardViewUpdateService, 'update');
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { setupTestBed } from '../../../../testing/setup-test-bed';
|
||||
import { CoreTestingModule } from '../../../../testing/core.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
@@ -46,29 +46,33 @@ describe('SelectFilterInputComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should focus input on initialization', async(() => {
|
||||
it('should focus input on initialization', async () => {
|
||||
spyOn(component.selectFilterInput.nativeElement, 'focus');
|
||||
matSelect.openedChange.next(true);
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(component.selectFilterInput.nativeElement.focus).toHaveBeenCalled();
|
||||
}));
|
||||
});
|
||||
|
||||
it('should clear search term on close', async(() => {
|
||||
it('should clear search term on close', async () => {
|
||||
component.onModelChange('some-search-term');
|
||||
expect(component.term).toBe('some-search-term');
|
||||
|
||||
matSelect.openedChange.next(false);
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(component.term).toBe('');
|
||||
}));
|
||||
await fixture.whenStable();
|
||||
|
||||
it('should emit event when value changes', async(() => {
|
||||
expect(component.term).toBe('');
|
||||
});
|
||||
|
||||
it('should emit event when value changes', async () => {
|
||||
spyOn(component.change, 'next');
|
||||
component.onModelChange('some-search-term');
|
||||
expect(component.change.next).toHaveBeenCalledWith('some-search-term');
|
||||
}));
|
||||
});
|
||||
|
||||
it('should reset value on reset() event', () => {
|
||||
component.onModelChange('some-search-term');
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { setupTestBed } from '../../../testing/setup-test-bed';
|
||||
import { CardViewDateItemModel } from '../../models/card-view-dateitem.model';
|
||||
@@ -45,21 +45,20 @@ describe('CardViewComponent', () => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should render the label and value', async(() => {
|
||||
it('should render the label and value', async () => {
|
||||
component.properties = [new CardViewTextItemModel({ label: 'My label', value: 'My value', key: 'some key' })];
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const labelValue = fixture.debugElement.query(By.css('.adf-property-label'));
|
||||
expect(labelValue).not.toBeNull();
|
||||
expect(labelValue.nativeElement.innerText).toBe('My label');
|
||||
const labelValue = fixture.debugElement.query(By.css('.adf-property-label'));
|
||||
expect(labelValue).not.toBeNull();
|
||||
expect(labelValue.nativeElement.innerText).toBe('My label');
|
||||
|
||||
const value = fixture.debugElement.query(By.css('.adf-property-value'));
|
||||
expect(value).not.toBeNull();
|
||||
expect(value.nativeElement.value).toBe('My value');
|
||||
});
|
||||
}));
|
||||
const value = fixture.debugElement.query(By.css('.adf-property-value'));
|
||||
expect(value).not.toBeNull();
|
||||
expect(value.nativeElement.value).toBe('My value');
|
||||
});
|
||||
|
||||
it('should pass through editable property to the items', () => {
|
||||
component.editable = true;
|
||||
@@ -76,28 +75,27 @@ describe('CardViewComponent', () => {
|
||||
expect(datePicker).not.toBeNull('Datepicker should be in DOM');
|
||||
});
|
||||
|
||||
it('should render the date in the correct format', async(() => {
|
||||
it('should render the date in the correct format', async () => {
|
||||
component.properties = [new CardViewDateItemModel({
|
||||
label: 'My date label',
|
||||
value: '2017-06-14',
|
||||
key: 'some key',
|
||||
format: 'short'
|
||||
})];
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const labelValue = fixture.debugElement.query(By.css('.adf-property-label'));
|
||||
expect(labelValue).not.toBeNull();
|
||||
expect(labelValue.nativeElement.innerText).toBe('My date label');
|
||||
const labelValue = fixture.debugElement.query(By.css('.adf-property-label'));
|
||||
expect(labelValue).not.toBeNull();
|
||||
expect(labelValue.nativeElement.innerText).toBe('My date label');
|
||||
|
||||
const value = fixture.debugElement.query(By.css('.adf-property-value'));
|
||||
expect(value).not.toBeNull();
|
||||
expect(value.nativeElement.innerText).toBe('6/14/17, 12:00 AM');
|
||||
});
|
||||
}));
|
||||
const value = fixture.debugElement.query(By.css('.adf-property-value'));
|
||||
expect(value).not.toBeNull();
|
||||
expect(value.nativeElement.innerText).toBe('6/14/17, 12:00 AM');
|
||||
});
|
||||
|
||||
it('should render the default value if the value is empty, not editable and displayEmpty is true', async(() => {
|
||||
it('should render the default value if the value is empty, not editable and displayEmpty is true', async () => {
|
||||
component.properties = [new CardViewTextItemModel({
|
||||
label: 'My default label',
|
||||
value: null,
|
||||
@@ -107,22 +105,20 @@ describe('CardViewComponent', () => {
|
||||
})];
|
||||
component.editable = true;
|
||||
component.displayEmpty = true;
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
const labelValue = fixture.debugElement.query(By.css('.adf-property-label'));
|
||||
expect(labelValue).not.toBeNull();
|
||||
expect(labelValue.nativeElement.innerText).toBe('My default label');
|
||||
|
||||
const labelValue = fixture.debugElement.query(By.css('.adf-property-label'));
|
||||
expect(labelValue).not.toBeNull();
|
||||
expect(labelValue.nativeElement.innerText).toBe('My default label');
|
||||
const value = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-some-key"]'));
|
||||
expect(value).not.toBeNull();
|
||||
expect(value.nativeElement.value).toBe('default value');
|
||||
});
|
||||
|
||||
const value = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-some-key"]'));
|
||||
expect(value).not.toBeNull();
|
||||
expect(value.nativeElement.value).toBe('default value');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should render the default value if the value is empty and is editable', async(() => {
|
||||
it('should render the default value if the value is empty and is editable', async () => {
|
||||
component.properties = [new CardViewTextItemModel({
|
||||
label: 'My default label',
|
||||
value: null,
|
||||
@@ -132,18 +128,16 @@ describe('CardViewComponent', () => {
|
||||
})];
|
||||
component.editable = true;
|
||||
component.displayEmpty = false;
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
const labelValue = fixture.debugElement.query(By.css('.adf-property-label'));
|
||||
expect(labelValue).not.toBeNull();
|
||||
expect(labelValue.nativeElement.innerText).toBe('My default label');
|
||||
|
||||
const labelValue = fixture.debugElement.query(By.css('.adf-property-label'));
|
||||
expect(labelValue).not.toBeNull();
|
||||
expect(labelValue.nativeElement.innerText).toBe('My default label');
|
||||
|
||||
const value = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-some-key"]'));
|
||||
expect(value).not.toBeNull();
|
||||
expect(value.nativeElement.value).toBe('default value');
|
||||
});
|
||||
}));
|
||||
const value = fixture.debugElement.query(By.css('[data-automation-id="card-textitem-value-some-key"]'));
|
||||
expect(value).not.toBeNull();
|
||||
expect(value.nativeElement.value).toBe('default value');
|
||||
});
|
||||
});
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { async } from '@angular/core/testing';
|
||||
import { fakeAsync } from '@angular/core/testing';
|
||||
import { CardViewSelectItemModel } from './card-view-selectitem.model';
|
||||
import { CardViewSelectItemProperties } from '../interfaces/card-view.interfaces';
|
||||
import { of } from 'rxjs';
|
||||
@@ -35,7 +35,7 @@ describe('CardViewSelectItemModel', () => {
|
||||
});
|
||||
|
||||
describe('displayValue', () => {
|
||||
it('should return the value if it is present', async(() => {
|
||||
it('should return the value if it is present', fakeAsync(() => {
|
||||
const itemModel = new CardViewSelectItemModel(properties);
|
||||
|
||||
itemModel.displayValue.subscribe((value) => {
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { MinimalNode } from '@alfresco/js-api';
|
||||
import { async, TestBed } from '@angular/core/testing';
|
||||
import { fakeAsync, TestBed } from '@angular/core/testing';
|
||||
import { CardViewBaseItemModel } from '../models/card-view-baseitem.model';
|
||||
import { CardViewUpdateService, transformKeyToObject } from './card-view-update.service';
|
||||
|
||||
@@ -63,7 +63,7 @@ describe('CardViewUpdateService', () => {
|
||||
cardViewUpdateService = TestBed.inject(CardViewUpdateService);
|
||||
});
|
||||
|
||||
it('should send updated message with proper parameters', async(() => {
|
||||
it('should send updated message with proper parameters', fakeAsync(() => {
|
||||
|
||||
cardViewUpdateService.itemUpdated$.subscribe(
|
||||
( { target, changed } ) => {
|
||||
@@ -74,7 +74,7 @@ describe('CardViewUpdateService', () => {
|
||||
cardViewUpdateService.update(property, 'changed-property-value');
|
||||
}));
|
||||
|
||||
it('should send clicked message with proper parameters', async(() => {
|
||||
it('should send clicked message with proper parameters', fakeAsync(() => {
|
||||
|
||||
cardViewUpdateService.itemClicked$.subscribe(
|
||||
( { target } ) => {
|
||||
@@ -84,7 +84,7 @@ describe('CardViewUpdateService', () => {
|
||||
cardViewUpdateService.clicked(property);
|
||||
}));
|
||||
|
||||
it('should send updated node when aspect changed', async(() => {
|
||||
it('should send updated node when aspect changed', fakeAsync(() => {
|
||||
const fakeNode: MinimalNode = <MinimalNode> { id: 'Bigfoot'};
|
||||
cardViewUpdateService.updatedAspect$.subscribe((node: MinimalNode) => {
|
||||
expect(node.id).toBe('Bigfoot');
|
||||
|
Reference in New Issue
Block a user