Merge Request #29
-
Reassigned to @mfdeveloper
-
Não seria mais indicado utilizar
jasmine.createSpy("confirmation")oujasmine.createSpyObj("notificationService", ["confirmation"])como já está amplamente utilizado em outros testes? As diversas formas para implementar coisas muito semelhantes pode causar confusão no futuro. Chegou a conversar rapidamente com @abner sobre isso? -
Não sei direito qual a diferença. Como não estava conseguindo utilizar o jasmine.createSpy, vi isto na documentação do jasmine e utilizei.
-
Se ocorrer um problema, essa mensagem será exibida para o usuário final?
-
Está conforme foi feito nos outros callbacks de serviços. Ach que tem ser feita uma revisão geral de como será o padrão de funcionamento das mensagens de erro.
-
Como esse catch aí é num componente de tela, então deveria estar utilizando o NotificationService para exibir a mensagem de erro para o usuário. Os serviços não devem realmente tratar a exibição de mensagens, mas os componentes de tela devem.
-
As chaves
article.remove.success.titleearticle.remove.confirmation.titlesão específicas da tela de artigo? Outras telas não relacionadas com artigo poderão utilizar essas chaves?
| 67 | 69 | * Execute the delete method on the target component |
| 68 | 70 | */ |
| 69 | 71 | function doDeleteArticle() { |
| 72 | + // Create a mock for the notification service confirmation | |
| 73 | + spyOn(helper.component.notificationService, 'confirmation').and.callFake(function (params: Function) { | |
| 2 |
|
|
| 33 | 34 | } |
| 35 | + this.notificationService.success({ title: "article.remove.success.title", message: "article.remove.success.message" }); | |
| 34 | 36 | }); |
| 35 | 37 | } |
| 36 | 38 | |
| 37 | 39 | delete() { |
| 38 | - this.articleService.removeArticle(this.article).catch((cause: any) => { | |
| 39 | - throw new Error(`Problem removing the article: ${cause}`); | |
| 40 | + this.notificationService.confirmation({ title: "article.remove.confirmation.title", message: "article.remove.confirmation.message" }, () => { | |
| 41 | + this.doDelete(); | |
| 40 | 42 | }); |
| 41 | 43 | } |
| 42 | 44 | |
| 45 | + doDelete() { | |
| 46 | + this.articleService.removeArticle(this.article).catch((cause: any) => { | |
| 47 | + throw new Error(`Problem removing the article: ${cause}`); | |
| 3 |
|
|
| 53 | 53 | "article.basic_editor.cancel": "Cancelar", |
| 54 | 54 | "article.basic_editor.success.title": "Bom trabalho!", |
| 55 | 55 | "article.basic_editor.success.message": "Artigo salvo com sucesso!", |
| 56 | + "article.remove.success.title": "Bom trabalho!", | |
| 1 |
|
|