我正在做一个有角度的项目,并且正在尝试为此方法编写单元测试:
showDocuments(): boolean {
return this.case && this.case.documentList &&
this.case.documentList.hasDocuments() || !this.case.documentList.isSucceeded;
}
直到现在我要进行测试:
it('should show document', () => {
expect(component).toBeDefined();
});
谢谢
这是
DocumentListModel
import { DocumentModel } from 'afw/models';
/**
* The model for documents that contains information about all the documents of the user
* and document store queue for particular case number.
*/
export class DocumentListModel {
/**
* Indicator of how many documents there are in the queue
*/
documentsInQueue?: number;
/**
* The actual documents
*/
documents: Array<DocumentModel>;
/**
* Whether the DMS succeeded
*/
isSucceeded: boolean;
/**
* Whether there is anything to display
*/
hasDocuments() {
return this.isSucceeded && this.documents && this.documents.length > 0 || this.documentsInQueue > 0;
}
/**
* Constructor
*/
constructor(item?: DocumentListModel) {
if (item) {
Object.assign(this, item);
}
}
}
有一个文档,该文档可以包含零个或多个附件