|
|
@ -79,10 +79,13 @@ describe('DialogService', () => { |
|
|
dialog.complete(confirmed); |
|
|
dialog.complete(confirmed); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
dialogService.confirm('MyTitle', 'MyText').subscribe(result => { |
|
|
dialogService.confirm('MyTitle', 'MyText').subscribe({ |
|
|
isNext = result; |
|
|
next: result => { |
|
|
}, undefined, () => { |
|
|
isNext = result; |
|
|
isCompleted = true; |
|
|
}, |
|
|
|
|
|
complete: () => { |
|
|
|
|
|
isCompleted = true; |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
expect(isCompleted).toBeTruthy(); |
|
|
expect(isCompleted).toBeTruthy(); |
|
|
@ -93,10 +96,10 @@ describe('DialogService', () => { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
[ |
|
|
[ |
|
|
{ confirmed: true, saved: 1 }, |
|
|
{ confirmed: true, saved: 1 }, |
|
|
{ confirmed: false, saved: 2 } |
|
|
{ confirmed: false, saved: 0 } |
|
|
].map(({ confirmed, saved }) => { |
|
|
].map(({ confirmed, saved }) => { |
|
|
it(`should confirm dialog with '${confirmed}' and remember when remembered`, () => { |
|
|
it(`should confirm dialog with '${confirmed}' and remember when remembered and confirmed`, () => { |
|
|
const dialogService = new DialogService(localStore.object); |
|
|
const dialogService = new DialogService(localStore.object); |
|
|
|
|
|
|
|
|
let isCompleted = false; |
|
|
let isCompleted = false; |
|
|
@ -107,47 +110,53 @@ describe('DialogService', () => { |
|
|
dialog.complete(confirmed); |
|
|
dialog.complete(confirmed); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
dialogService.confirm('MyTitle', 'MyText', 'MyKey').subscribe(result => { |
|
|
dialogService.confirm('MyTitle', 'MyText', 'MyKey').subscribe({ |
|
|
isNext = result; |
|
|
next: result => { |
|
|
}, undefined, () => { |
|
|
isNext = result; |
|
|
isCompleted = true; |
|
|
}, |
|
|
|
|
|
complete: () => { |
|
|
|
|
|
isCompleted = true; |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
expect(isCompleted).toBeTruthy(); |
|
|
expect(isCompleted).toBeTruthy(); |
|
|
expect(isNext!).toEqual(confirmed); |
|
|
expect(isNext!).toEqual(confirmed); |
|
|
|
|
|
|
|
|
localStore.verify(x => x.setInt(`dialogs.confirm.MyKey`, saved), Times.once()); |
|
|
localStore.verify(x => x.setBoolean(`dialogs.confirm.MyKey`, It.isAny()), Times.exactly(saved)); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
[ |
|
|
[ |
|
|
{ confirmed: true, saved: 1 }, |
|
|
{ confirmed: true, saved: true, render: 0 }, |
|
|
{ confirmed: false, saved: 2 } |
|
|
{ confirmed: false, saved: false, render: 1 } |
|
|
].map(({ confirmed, saved }) => { |
|
|
].map(({ confirmed, saved, render }) => { |
|
|
it(`should confirm dialog with '${confirmed}' from local store when saved`, () => { |
|
|
it(`should confirm dialog with '${confirmed}' from local store when saved`, () => { |
|
|
const dialogService = new DialogService(localStore.object); |
|
|
const dialogService = new DialogService(localStore.object); |
|
|
|
|
|
|
|
|
localStore.setup(x => x.getInt(`dialogs.confirm.MyKey`)) |
|
|
localStore.setup(x => x.getBoolean(`dialogs.confirm.MyKey`)) |
|
|
.returns(() => saved); |
|
|
.returns(() => saved); |
|
|
|
|
|
|
|
|
let requestCount = 0; |
|
|
let requestCount = 0; |
|
|
|
|
|
|
|
|
let isCompleted = false; |
|
|
let isCompleted = false; |
|
|
let isNext: boolean; |
|
|
let isNext: boolean | undefined; |
|
|
|
|
|
|
|
|
dialogService.dialogs.subscribe(_ => { |
|
|
dialogService.dialogs.subscribe(_ => { |
|
|
requestCount++; |
|
|
requestCount++; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
dialogService.confirm('MyTitle', 'MyText', 'MyKey').subscribe(result => { |
|
|
dialogService.confirm('MyTitle', 'MyText', 'MyKey').subscribe({ |
|
|
isNext = result; |
|
|
next: result => { |
|
|
}, undefined, () => { |
|
|
isNext = result; |
|
|
isCompleted = true; |
|
|
}, |
|
|
|
|
|
complete: () => { |
|
|
|
|
|
isCompleted = true; |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
expect(isCompleted).toBeTruthy(); |
|
|
expect(isCompleted).toEqual(confirmed); |
|
|
expect(isNext!).toEqual(confirmed); |
|
|
expect(isNext).toEqual(confirmed ? true : undefined); |
|
|
expect(requestCount).toEqual(0); |
|
|
expect(requestCount).toEqual(render); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|