-
Notifications
You must be signed in to change notification settings - Fork 672
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix travis docs: add cache unit test test: add abc test
- Loading branch information
Showing
80 changed files
with
3,547 additions
and
873 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { TestBed, ComponentFixture } from '@angular/core/testing'; | ||
import { Component, DebugElement, ViewChild } from '@angular/core'; | ||
import { AdCountDownModule } from './count-down.module'; | ||
import { By } from '@angular/platform-browser'; | ||
import * as moment from 'moment'; | ||
|
||
describe('abc: count-down', () => { | ||
let fixture: ComponentFixture<TestComponent>; | ||
let dl: DebugElement; | ||
let context: TestComponent; | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.configureTestingModule({ | ||
imports: [ AdCountDownModule.forRoot() ], | ||
declarations: [ TestComponent ] | ||
}).createComponent(TestComponent); | ||
dl = fixture.debugElement; | ||
context = fixture.componentInstance; | ||
}); | ||
|
||
it('should be create an instance via [config]', (done: () => void) => { | ||
spyOn(context, 'begin'); | ||
spyOn(context, 'notify'); | ||
spyOn(context, 'end'); | ||
context.config = { | ||
leftTime: 2, | ||
notify: [ 1.5 ] | ||
}; | ||
fixture.detectChanges(); | ||
setTimeout(() => { | ||
expect(context.begin).toHaveBeenCalled(); | ||
expect(context.notify).toHaveBeenCalled(); | ||
expect(context.end).toHaveBeenCalled(); | ||
done(); | ||
}, 2000 + 20); | ||
}); | ||
|
||
it('should be create an instance via [target]', (done: () => void) => { | ||
spyOn(context, 'end'); | ||
context.target = 1; | ||
fixture.detectChanges(); | ||
setTimeout(() => { | ||
expect(context.end).toHaveBeenCalled(); | ||
done(); | ||
}, 1000 + 20); | ||
}); | ||
|
||
it('should be create an instance when target is date', (done: () => void) => { | ||
spyOn(context, 'end'); | ||
context.target = moment().add(1, 's').toDate(); | ||
fixture.detectChanges(); | ||
setTimeout(() => { | ||
expect(context.end).toHaveBeenCalled(); | ||
done(); | ||
}, 1000 + 20); | ||
}); | ||
}); | ||
|
||
@Component({ | ||
template: ` | ||
<div *ngIf="config"> | ||
<count-down | ||
[config]="config" | ||
(begin)="begin()" | ||
(end)="end()" | ||
(notify)="notify($event)" style="font-size: 20px"></count-down> | ||
</div> | ||
<div *ngIf="target"> | ||
<count-down | ||
[target]="target" | ||
(begin)="begin()" | ||
(end)="end()" | ||
(notify)="notify($event)" style="font-size: 20px"></count-down> | ||
</div>` | ||
}) | ||
class TestComponent { | ||
config: any; | ||
target: number | Date; | ||
notify(val: number) { | ||
console.log(val); | ||
} | ||
begin() { | ||
console.log('begin'); | ||
} | ||
end() { | ||
console.log('end'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { TestBed, ComponentFixture } from '@angular/core/testing'; | ||
import { Component, DebugElement } from '@angular/core'; | ||
import { AdDescListModule } from './desc-list.module'; | ||
import { By } from '@angular/platform-browser'; | ||
|
||
describe('abc: desc-list', () => { | ||
let fixture: ComponentFixture<TestComponent>; | ||
let dl: DebugElement; | ||
let context: TestComponent; | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.configureTestingModule({ | ||
imports: [ AdDescListModule.forRoot() ], | ||
declarations: [ TestComponent ] | ||
}).createComponent(TestComponent); | ||
dl = fixture.debugElement; | ||
context = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should be create an instance', () => { | ||
expect(context).not.toBeNull(); | ||
expect(dl.queryAll(By.css('#defaultDL .term')).length).toBe(3); | ||
}); | ||
|
||
it('should be custome title template', () => { | ||
expect(dl.queryAll(By.css('#custom-title-template #titleTpl')).length).toBe(1); | ||
}); | ||
|
||
it('should be changed property', () => { | ||
expect(dl.queryAll(By.css('.large')).length).toBe(1); | ||
// because of two desc-list component | ||
expect(dl.queryAll(By.css('.horizontal')).length).toBe(2); | ||
expect(dl.queryAll(By.css('.vertical')).length).toBe(0); | ||
context.size = 'small'; | ||
context.layout = 'vertical'; | ||
context.col = 5; | ||
fixture.detectChanges(); | ||
expect(dl.queryAll(By.css('.large')).length).toBe(0); | ||
expect(dl.queryAll(By.css('.horizontal')).length).toBe(1); | ||
expect(dl.queryAll(By.css('.vertical')).length).toBe(1); | ||
}); | ||
}); | ||
|
||
@Component({ | ||
template: ` | ||
<desc-list id="defaultDL" | ||
[size]="size" | ||
[title]="'title'" | ||
[gutter]="gutter" | ||
[layout]="layout" | ||
[col]="col" | ||
> | ||
<desc-list-item term="Firefox"> | ||
A free, open source, cross-platform, | ||
graphical web browser developed by the | ||
Mozilla Corporation and hundreds of | ||
volunteers. | ||
</desc-list-item> | ||
<desc-list-item term="Firefox"> | ||
A free, open source, cross-platform, | ||
graphical web browser developed by the | ||
Mozilla Corporation and hundreds of | ||
volunteers. | ||
</desc-list-item> | ||
<desc-list-item [term]="termTpl"> | ||
<ng-template #termTpl><p id="termTpl">termTpl</p></ng-template> | ||
</desc-list-item> | ||
</desc-list> | ||
<desc-list id="custom-title-template" | ||
[title]="title" | ||
[gutter]="gutter" | ||
> | ||
<ng-template #title> | ||
<p id="titleTpl">titleTpl</p> | ||
</ng-template> | ||
<desc-list-item term="Firefox"> | ||
A free, open source, cross-platform, | ||
graphical web browser developed by the | ||
Mozilla Corporation and hundreds of | ||
volunteers. | ||
</desc-list-item> | ||
</desc-list>` | ||
}) | ||
class TestComponent { | ||
size: 'small' | 'large' = 'large'; | ||
gutter = 32; | ||
layout: 'horizontal' | 'vertical' = 'horizontal'; | ||
col = 3; | ||
} |
Oops, something went wrong.