Skip to content

Commit

Permalink
build: add noUnusedLocals config (NG-ZORRO#2959)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendell authored and vthinkxie committed Feb 24, 2019
1 parent 62bfeea commit 6114fbb
Show file tree
Hide file tree
Showing 111 changed files with 67 additions and 271 deletions.
11 changes: 2 additions & 9 deletions components/affix/affix.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, DebugElement, ViewChild, ViewEncapsulation } from '@angular/core';
import { Component, DebugElement, ViewChild } from '@angular/core';
import {
discardPeriodicTasks,
fakeAsync,
Expand Down Expand Up @@ -188,7 +188,6 @@ describe('affix', () => {

describe('[nzOffsetTop]', () => {
const offsetTop = 150;
const componentOffset = 160;

beforeEach(() => {
context.newOffset = offsetTop;
Expand Down Expand Up @@ -466,18 +465,15 @@ describe('affix-extra', () => {
let fixture: ComponentFixture<TestAffixComponent>;
let context: TestAffixComponent;
let dl: DebugElement;
let component: NzAffixComponent;
let page: PageObject;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [NzAffixModule],
declarations: [TestAffixComponent]
}).compileComponents();
fixture = TestBed.createComponent(TestAffixComponent);
context = fixture.componentInstance;
component = context.nzAffixComponent;
dl = fixture.debugElement;
page = new PageObject();
});
it('#getOffset', () => {
const ret = fixture.componentInstance.nzAffixComponent.getOffset(fixture.debugElement.query(By.css('#affix')).nativeElement, window);
Expand All @@ -504,9 +500,6 @@ describe('affix-extra', () => {
const ret = +(el.querySelector('.ant-affix') as HTMLElement).style.bottom.replace('px', '');
expect(ret).toBe(value);
}));
class PageObject {

}
});

@Component({
Expand Down
3 changes: 1 addition & 2 deletions components/affix/nz-affix.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { DOCUMENT } from '@angular/common';
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
ElementRef,
EventEmitter,
Expand Down Expand Up @@ -66,7 +65,7 @@ export class NzAffixComponent implements OnInit, OnDestroy {
readonly nzChange: EventEmitter<boolean> = new EventEmitter();

// tslint:disable-next-line:no-any
constructor(_el: ElementRef, private scrollSrv: NzScrollService, @Inject(DOCUMENT) private doc: any, private cd: ChangeDetectorRef) {
constructor(_el: ElementRef, private scrollSrv: NzScrollService, @Inject(DOCUMENT) private doc: any) {
this.placeholderNode = _el.nativeElement;
}

Expand Down
4 changes: 2 additions & 2 deletions components/alert/nz-alert.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ describe('alert', () => {
});
describe('banner alert', () => {
let fixture;
let testComponent;
let alert;

beforeEach(() => {
fixture = TestBed.createComponent(NzDemoTestBannerComponent);
fixture.detectChanges();
testComponent = fixture.debugElement.componentInstance;
alert = fixture.debugElement.query(By.directive(NzAlertComponent));
});

it('should banner work', () => {
fixture.detectChanges();
expect(alert.nativeElement.querySelector('.ant-alert').classList).toContain(`ant-alert-warning`);
Expand Down
3 changes: 1 addition & 2 deletions components/anchor/anchor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// tslint:disable
import { fakeAsync, tick, TestBed, ComponentFixture, async } from '@angular/core/testing';
import { fakeAsync, tick, TestBed, ComponentFixture } from '@angular/core/testing';
import { Component, DebugElement, ViewChild } from '@angular/core';
import { By } from '@angular/platform-browser';
import { NzAnchorModule } from './nz-anchor.module';
import { NzAnchorComponent } from './nz-anchor.component';
import { NzAnchorLinkComponent } from './nz-anchor-link.component';
import { NzScrollService } from '../core/scroll/nz-scroll.service';

const throttleTime = 51;
Expand Down
1 change: 0 additions & 1 deletion components/anchor/nz-anchor-link.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
Component,
ContentChild,
ElementRef,
HostBinding,
Input,
OnDestroy,
OnInit, Renderer2,
Expand Down
2 changes: 0 additions & 2 deletions components/auto-complete/nz-autocomplete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -831,12 +831,10 @@ describe('auto-complete', () => {

describe('Fallback positions', () => {
let fixture;
let input: HTMLInputElement;

beforeEach(() => {
fixture = TestBed.createComponent(NzTestSimpleAutocompleteComponent);
fixture.detectChanges();
input = fixture.debugElement.query(By.css('input')).nativeElement;
});

it('should use bottom positioning by default', fakeAsync(() => {
Expand Down
4 changes: 0 additions & 4 deletions components/back-top/back-top.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { NzBackTopModule } from './nz-back-top.module';
describe('Component:nz-back-top', () => {
let scrollService: MockNzScrollService;
let fixture: ComponentFixture<TestBackTopComponent>;
let context: TestBackTopComponent;
let debugElement: DebugElement;
let component: NzBackTopComponent;
let componentObject: NzBackTopPageObject;
Expand Down Expand Up @@ -57,7 +56,6 @@ describe('Component:nz-back-top', () => {
}).compileComponents();

fixture = TestBed.createComponent(TestBackTopComponent);
context = fixture.componentInstance;
component = fixture.componentInstance.nzBackTopComponent;
componentObject = new NzBackTopPageObject();
debugElement = fixture.debugElement;
Expand Down Expand Up @@ -199,9 +197,7 @@ describe('Component:nz-back-top', () => {
describe('#nzTemplate', () => {
it(`should show custom template`, fakeAsync(() => {
let fixtureTemplate: ComponentFixture<TestBackTopTemplateComponent>;
let contextTemplate: TestBackTopTemplateComponent;
fixtureTemplate = TestBed.createComponent(TestBackTopTemplateComponent);
contextTemplate = fixture.componentInstance;

componentObject.scrollTo(window, defaultVisibilityHeight + 1);
tick();
Expand Down
2 changes: 1 addition & 1 deletion components/breadcrumb/nz-breadcrumb-item.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, TemplateRef, ViewEncapsulation } from '@angular/core';
import { ChangeDetectionStrategy, Component, ViewEncapsulation } from '@angular/core';

import { NzBreadCrumbComponent } from './nz-breadcrumb.component';

Expand Down
5 changes: 0 additions & 5 deletions components/breadcrumb/nz-breadcrumb.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { NzBreadCrumbComponent } from './nz-breadcrumb.component';
import { NzBreadCrumbModule } from './nz-breadcrumb.module';

describe('breadcrumb', () => {
let testComponent;
let fixture;

describe('basic', () => {
Expand All @@ -31,7 +30,6 @@ describe('breadcrumb', () => {

beforeEach(() => {
fixture = TestBed.createComponent(NzDemoBreadcrumbBasicComponent);
testComponent = fixture.debugElement.componentInstance;
items = fixture.debugElement.queryAll(By.directive(NzBreadCrumbItemComponent));
breadcrumb = fixture.debugElement.query(By.directive(NzBreadCrumbComponent));
});
Expand All @@ -56,7 +54,6 @@ describe('breadcrumb', () => {

beforeEach(() => {
fixture = TestBed.createComponent(NzDemoBreadcrumbSeparatorComponent);
testComponent = fixture.debugElement.componentInstance;
items = fixture.debugElement.queryAll(By.directive(NzBreadCrumbItemComponent));
breadcrumbs = fixture.debugElement.queryAll(By.directive(NzBreadCrumbComponent));
});
Expand All @@ -83,7 +80,6 @@ describe('breadcrumb', () => {
declarations: [ NzBreadcrumbAutoGenerateDemoComponent, NzBreadcrumbNullComponent ]
}).compileComponents();
fixture = TestBed.createComponent(NzBreadcrumbAutoGenerateDemoComponent);
testComponent = fixture.debugElement.componentInstance;
breadcrumb = fixture.debugElement.query(By.directive(NzBreadCrumbComponent));

fixture.ngZone.run(() => {
Expand Down Expand Up @@ -125,7 +121,6 @@ describe('breadcrumb', () => {
expect(() => {
TestBed.compileComponents();
fixture = TestBed.createComponent(NzBreadcrumbAutoGenerateErrorDemoComponent);
testComponent = fixture.debugElement.componentInstance;
fixture.detectChanges();
}).toThrowError();
}));
Expand Down
2 changes: 0 additions & 2 deletions components/calendar/nz-calendar-header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ export class NzCalendarHeaderComponent implements OnInit {
return this.i18n.getLocale().Calendar.month;
}

private prefixCls = 'ant-fullcalendar';

constructor(private i18n: I18n, private dateHelper: DateHelperService) {
}

Expand Down
4 changes: 1 addition & 3 deletions components/calendar/nz-calendar-header.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,9 @@ describe('Calendar Header', () => {

describe('activeDate', () => {
let fixture: ComponentFixture<NzTestCalendarHeaderActiveDateComponent>;
let component: NzTestCalendarHeaderActiveDateComponent;

beforeEach(async(() => {
fixture = TestBed.createComponent(NzTestCalendarHeaderActiveDateComponent);
component = fixture.componentInstance;
}));

it('should be now by default', () => {
Expand Down Expand Up @@ -164,7 +162,7 @@ describe('Calendar Header', () => {
it('should emit monthChange when month changed', () => {
fixture.detectChanges();
const header = fixture.debugElement.queryAll(By.directive(CalendarHeader))[0];
const [_, monthModel] = header.queryAll(By.directive(Select)).map(x => x.injector.get(NgModel));
const monthModel = header.queryAll(By.directive(Select)).map(x => x.injector.get(NgModel))[1];

monthModel.viewToModelUpdate(2);

Expand Down
1 change: 0 additions & 1 deletion components/calendar/nz-calendar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export class NzCalendarComponent implements ControlValueAccessor, OnInit {
monthCell: TemplateRef<{$implicit: Date}>|null = null;
monthFullCell: TemplateRef<{$implicit: Date}>|null = null;

private prefixCls = 'ant-fullcalendar';
private currentDate = new Date();
private onChangeFn: (date: Date) => void = () => {};
private onTouchFn: () => void = () => {};
Expand Down
8 changes: 0 additions & 8 deletions components/calendar/nz-calendar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,9 @@ describe('Calendar', () => {

describe('dateCell', () => {
let fixture: ComponentFixture<NzTestCalendarDateCellComponent>;
let component: NzTestCalendarDateCellComponent;

beforeEach(async(() => {
fixture = TestBed.createComponent(NzTestCalendarDateCellComponent);
component = fixture.componentInstance;
}));

it('should work when passed via property', () => {
Expand All @@ -306,11 +304,9 @@ describe('Calendar', () => {

describe('dateFullCell', () => {
let fixture: ComponentFixture<NzTestCalendarDateFullCellComponent>;
let component: NzTestCalendarDateFullCellComponent;

beforeEach(async(() => {
fixture = TestBed.createComponent(NzTestCalendarDateFullCellComponent);
component = fixture.componentInstance;
}));

it('should work when passed via property', () => {
Expand All @@ -334,11 +330,9 @@ describe('Calendar', () => {

describe('monthCell', () => {
let fixture: ComponentFixture<NzTestCalendarMonthCellComponent>;
let component: NzTestCalendarMonthCellComponent;

beforeEach(async(() => {
fixture = TestBed.createComponent(NzTestCalendarMonthCellComponent);
component = fixture.componentInstance;
}));

it('should work when passed via property', () => {
Expand All @@ -362,11 +356,9 @@ describe('Calendar', () => {

describe('monthFullCell', () => {
let fixture: ComponentFixture<NzTestCalendarMonthFullCellComponent>;
let component: NzTestCalendarMonthFullCellComponent;

beforeEach(async(() => {
fixture = TestBed.createComponent(NzTestCalendarMonthFullCellComponent);
component = fixture.componentInstance;
}));

it('should work when passed via property', () => {
Expand Down
2 changes: 0 additions & 2 deletions components/cascader/nz-cascader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ describe('cascader', () => {
it('should showArrow work', () => {
testComponent.nzShowArrow = true;
fixture.detectChanges();
const arrow: HTMLElement = cascader.nativeElement.querySelector('.ant-cascader-picker-arrow');
expect(cascader.nativeElement.querySelector('.ant-cascader-picker-arrow')).toBeDefined();
expect(cascader.nativeElement.querySelector('.ant-cascader-picker-arrow').classList).toContain('anticon-down');
testComponent.nzShowArrow = false;
Expand All @@ -135,7 +134,6 @@ describe('cascader', () => {
});
it('should allowClear work', () => {
fixture.detectChanges();
const input: HTMLElement = cascader.nativeElement.querySelector('.ant-cascader-input');
testComponent.values = [ 'zhejiang', 'hangzhou', 'xihu' ];
fixture.detectChanges();
expect(cascader.nativeElement.querySelector('.ant-cascader-picker-clear')).toBeDefined();
Expand Down
4 changes: 0 additions & 4 deletions components/collapse/nz-collapse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,10 @@ describe('collapse', () => {
});
describe('collapse template', () => {
let fixture;
let testComponent;
let collapse;
let panels;
beforeEach(() => {
fixture = TestBed.createComponent(NzTestCollapseTemplateComponent);
fixture.detectChanges();
testComponent = fixture.debugElement.componentInstance;
collapse = fixture.debugElement.query(By.directive(NzCollapseComponent));
panels = fixture.debugElement.queryAll(By.directive(NzCollapsePanelComponent));
});
it('should header work', () => {
Expand Down
2 changes: 0 additions & 2 deletions components/core/scroll/nz-scroll.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ describe('NzScrollService', () => {
const TOP: number = 10;
let injector: ReflectiveInjector;
let document: MockDocument;
let location: MockPlatformLocation;
let scrollService: NzScrollService;

class MockDocument {
Expand Down Expand Up @@ -39,7 +38,6 @@ describe('NzScrollService', () => {
{ provide: DOCUMENT, useClass: MockDocument },
{ provide: PlatformLocation, useClass: MockPlatformLocation }
]);
location = injector.get(PlatformLocation);
document = injector.get(DOCUMENT);
scrollService = injector.get(NzScrollService);
});
Expand Down
3 changes: 0 additions & 3 deletions components/core/wave/nz-wave.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const EXTRA_NODE_CLASS_NAME = '.ant-click-animating-node';
describe('nz-wave', () => {
let fixture: ComponentFixture<WaveContainerWithButtonComponent | WaveContainerWithExtraNodeComponent>;
let waveTarget: HTMLElement;
let waveDirective: NzWaveDirective;

beforeEach(() => {
TestBed.configureTestingModule({
Expand All @@ -29,7 +28,6 @@ describe('nz-wave', () => {
fixture = TestBed.createComponent(WaveContainerWithButtonComponent);
fixture.detectChanges();
waveTarget = fixture.componentInstance.trigger.nativeElement;
waveDirective = fixture.componentInstance.wave;
});

it('should create wave on click', () => {
Expand Down Expand Up @@ -114,7 +112,6 @@ describe('nz-wave', () => {
fixture = TestBed.createComponent(WaveContainerWithExtraNodeComponent);
fixture.detectChanges();
waveTarget = fixture.componentInstance.trigger.nativeElement;
waveDirective = fixture.componentInstance.wave;
});

it('should create wave on click', () => {
Expand Down
3 changes: 0 additions & 3 deletions components/date-picker/date-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import isSameDay from 'date-fns/is_same_day';

import en from 'date-fns/locale/en';
import { dispatchKeyboardEvent, dispatchMouseEvent } from '../core/testing';
import { NZ_DATE_CONFIG } from '../i18n/date-config';
import en_US from '../i18n/languages/en_US';
import { NzI18nModule } from '../i18n/nz-i18n.module';
import { NzI18nService } from '../i18n/nz-i18n.service';
Expand Down Expand Up @@ -527,7 +525,6 @@ describe('NzDatePickerComponent', () => {
}));

it('should support nzShowTime', fakeAsync(() => {
const nzOnChange = spyOn(fixtureInstance, 'nzOnChange');
fixtureInstance.nzValue = new Date('2018-11-11 11:22:33');
fixtureInstance.nzShowTime = true;
fixture.detectChanges();
Expand Down
2 changes: 1 addition & 1 deletion components/date-picker/demo/extra-footer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component } from '@angular/core';

@Component({
selector: 'nz-demo-date-picker-extra-footer',
Expand Down
2 changes: 0 additions & 2 deletions components/date-picker/month-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe('NzMonthPickerComponent', () => {
let fixture: ComponentFixture<NzTestMonthPickerComponent>;
let fixtureInstance: NzTestMonthPickerComponent;
let debugElement: DebugElement;
let overlayContainer: OverlayContainer;
let overlayContainerElement: HTMLElement;

beforeEach(fakeAsync(() => {
Expand All @@ -42,7 +41,6 @@ describe('NzMonthPickerComponent', () => {
});

beforeEach(inject([ OverlayContainer ], (oc: OverlayContainer) => {
overlayContainer = oc;
overlayContainerElement = oc.getContainerElement();
}));

Expand Down
1 change: 0 additions & 1 deletion components/date-picker/range-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ describe('NzRangePickerComponent', () => {
}));

it('should support nzShowTime', fakeAsync(() => {
const nzOnChange = spyOn(fixtureInstance, 'modelValueChange');
fixtureInstance.modelValue = [ new Date('2018-11-11 11:22:33'), new Date('2018-12-12 11:22:33') ];
fixtureInstance.nzShowTime = true;
fixture.detectChanges();
Expand Down
Loading

0 comments on commit 6114fbb

Please sign in to comment.