我目前在使用带有承诺的茉莉花测试时遇到问题。
错误是“未处理的承诺拒绝:”这意味着我的承诺没有正确处理catch(),then()我想。
这是我的测试:
it('tests the openRepo function with changed and invalid path', (done) => {
const OldPath = '/old';
const NewPath = '/invalid';
const ProjectModalBoolean = true;
component.path = OldPath;
component.openFolder = NewPath;
component.projectModalLoading = ProjectModalBoolean;
component.openRepo().then(() => {
expect(component.openFolder).toBe('');
expect(component.projectModalLoading).toBeFalsy();
done();
});
});
Run Code Online (Sandbox Code Playgroud)
在函数中openRepo我有以下代码:
return this.gitService.setPath(this.openFolder)
.then((data) => {
this.projectModalLoading = false;
this.projectModalVisible = false;
this.openFolder = '';
this.toastr.info(data.message, data.title);
})
.catch((data) => {
this.projectModalLoading = false;
this.openFolder = '';
this.toastr.error(data.message, data.title);
}); …Run Code Online (Sandbox Code Playgroud) 我想生成以下形式的树:
[
{
folder: 'src',
children: [
{
folder: 'app',
children: [
{ file: 'app.module.ts', status: 'M' },
{
folder: 'components',
children: [
{
folder: 'accordion',
children: [
{ file: 'accordion.components.scss', status: 'M'}
]
},
{
folder: 'file-diff-commit',
children: [
{ file: 'file-diff-commit.component.html', status: 'A' },
{ file: 'file-diff-commit.component.ts', status: 'A' }
]
}
]
},
{
folder: 'models',
children: [
{ file: 'MockGitService.ts' , status: 'M' },
{ file: 'MockLeftPanelService.ts', status: 'M'}
]
}
]
},
{
folder: 'assets' …Run Code Online (Sandbox Code Playgroud) 我目前正在尝试显示有关我的应用程序中特定提交的信息。
我想知道这些文件是否在本次提交中创建、修改或删除,但如果我使用git show,我得到的信息将是删除或添加的行数。