Skip to content

Commit

Permalink
feat(module: action_sheet): update testing coverage (#515)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guoyuanqiang authored and fisherspy committed Jul 30, 2019
1 parent 7f80c13 commit b74db68
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 54 deletions.
2 changes: 1 addition & 1 deletion components/action-sheet/action-sheet-options.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class ActionSheetOptions {
className?: string;
transitionName?: string = 'am-slide-up';
maskTransitionName?: string = 'am-fade';
locale?;
}

@Injectable()
Expand All @@ -23,7 +24,6 @@ export class ShareOption {
export class ShareActionSheetWithOptions extends ActionSheetOptions {
options: ShareOption[] | ShareOption[][];
cancelButtonText?: string = 'Cancel';
locale?;
}

@Injectable()
Expand Down
45 changes: 0 additions & 45 deletions components/action-sheet/action-sheet-subject.service.ts

This file was deleted.

30 changes: 27 additions & 3 deletions components/action-sheet/action-sheet.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ActionSheetComponent } from './action-sheet.component';
import { ActionSheet, ActionSheetModule, ButtonModule } from '../..';
import { NgZorroAntdMobilePipesModule } from '../pipes/ng-zorro-antd-mobile.pipes.module';
import { Overlay } from '@angular/cdk/overlay';
import { en_US } from '../locale-provider/locale';
describe('ActionSheetComponent', () => {
let component: TestActionSheetBasicComponent;
let fixture: ComponentFixture<TestActionSheetBasicComponent>;
Expand Down Expand Up @@ -73,6 +74,17 @@ describe('ActionSheetComponent', () => {
flush();
actionSheetEle = document.getElementsByTagName('actionsheet')[1];
expect(actionSheetEle.querySelector('.am-action-sheet-share-list')).toBeTruthy('shareactionsheet is work');
actionSheetEle.querySelector('.am-action-sheet-share-list-item').click();
fixture.detectChanges();
flush();
}));

it('should shareActionSheet work', fakeAsync(() => {
component.dataList = [];
const button = buttons[1].nativeElement;
button.click();
fixture.detectChanges();
flush();
}));

it('should shareActionSheetMulpitleLine work', fakeAsync(() => {
Expand Down Expand Up @@ -131,6 +143,17 @@ export class TestActionSheetBasicComponent {
icon: `<img src="https://gw.alipayobjects.com/zos/rmsportal/${obj.url}.png" style="width:36px"/>`,
title: obj.title
}));
dataList1 = [
{ url: 'OpHiXAcYzmPQHcdlLFrc', title: '发送给朋友' },
{ url: 'wvEzCMiDZjthhAOcwTOu', title: '新浪微博' },
{ url: 'cTTayShKtEIdQVEMuiWt', title: '生活圈' },
{ url: 'umnHwvEgSyQtXlZjNJTt', title: '微信好友' },
{ url: 'SxpunpETIwdxNjcJamwB', title: 'QQ' }
].map(obj => ({
icon: `<img src="https://gw.alipayobjects.com/zos/rmsportal/${obj.url}.png" style="width:36px"/>`,
title: obj.title
}));
locale = en_US;

@ViewChild('message')
message: ViewChild;
Expand All @@ -144,9 +167,10 @@ export class TestActionSheetBasicComponent {
options: BUTTONS,
cancelButtonIndex: BUTTONS.length - 1,
destructiveButtonIndex: BUTTONS.length - 2,
title: 'action-title',
title: null,
message: message,
maskClosable: true
maskClosable: true,
locale: this.locale
},
buttonIndex => {
console.log(buttonIndex);
Expand All @@ -170,7 +194,7 @@ export class TestActionSheetBasicComponent {
}

showShareActionSheetMulpitleLine = () => {
const data = [[...this.dataList, this.dataList[2]], [this.dataList[3], this.dataList[4]]];
const data = [[...this.dataList1, this.dataList1[2]], [this.dataList1[3], this.dataList1[4]]];
ActionSheet.showShareActionSheetWithOptions(
{
options: data,
Expand Down
5 changes: 1 addition & 4 deletions components/action-sheet/action-sheet.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ export class ActionSheetComponent implements OnInit, OnDestroy {
}

isTemplateRef(value) {
if (value) {
return value instanceof TemplateRef;
}
return false;
return value instanceof TemplateRef;
}

isArray(options: any, value: any) {
Expand Down
1 change: 0 additions & 1 deletion components/action-sheet/public-api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export { ActionSheetModule } from './action-sheet.module';
export { ActionSheetComponent } from './action-sheet.component';
export { ActionSheetSubjectService } from './action-sheet-subject.service';
export { ActionSheetService, ActionSheetService as ActionSheet } from './action-sheet.service';
export { ActionSheetOptions, ShareOption, ShareActionSheetWithOptions, ActionSheetWithOptions, ActionCallBack } from './action-sheet-options.provider';

0 comments on commit b74db68

Please sign in to comment.