Merge Request #11
-
Reassigned to @mfdeveloper
-
Why did you instantiate the
BasicEditorComponent"by hand" here? What do you think about usage of theComponentTestHelperto more clean unit specs? -
It is a legacy code, I just include the missing parameter to fix the test.
-
Sure! It's ok for me :)
-
Why did you not use
ComponentTestHelperclass? -
It's a legacy code, I just move this file to another folder. I'll refactor it and apply your considerations.
-
It is necessary? Seems redundant for me, no?
-
Sadly yes. The alternative here is to use ProfileService as the parameter name. However, it works seamlessly in components that don't uses ui-roter directly (e.g. members-block.component.ts).
-
I understand now. This is a ng-foward constraint?
-
Why did you use
$rootScopein this case? Did you try usedetectChanges()ng-forward method? -
It's a legacy code, I just move this file to another folder. I'll refactor it and apply your considerations.
-
Can be this key more generic? Something like:
actions.editonly. This is not specific article action -
Not sure...sometimes we want to change only this specific label to something like "Edit Article"
-
Milestone changed to 2016.05
-
mentioned in commit 1894afc0521954895e6b817afa85c8c4a51e8d5e
-
Assignee removed
| 31 | 33 | articleCreate.resolve({ data: { path: "path", profile: { identifier: "profile" } } }); |
| 32 | 34 | |
| 33 | 35 | profileServiceMock.getCurrentProfile = jasmine.createSpy("getCurrentProfile").and.returnValue(getCurrentProfileResponse.promise); |
| 34 | - articleServiceMock.createInProfile = jasmine.createSpy("createInProfile").and.returnValue(articleCreate.promise); | |
| 36 | + articleServiceMock.createInParent = jasmine.createSpy("createInParent").and.returnValue(articleCreate.promise); | |
| 35 | 37 | }); |
| 36 | 38 | |
| 37 | 39 | it("create an article in the current profile when save", done => { |
| 38 | - let component: BasicEditorComponent = new BasicEditorComponent(articleServiceMock, profileServiceMock, $state, notification); | |
| 3 |
|
|
| 44 | 47 | }); |
| 45 | 48 | }); |
| 46 | 49 | |
| 50 | + it('return article parent as container when it is not a folder', (done: Function) => { | |
| 51 | + buildComponent().then((fixture: ComponentFixture) => { | |
| 52 | + let component = fixture.debugElement.componentViewChildren[0].componentInstance; | |
| 2 |
|
|
| 1 | 1 | import {Component, Inject, provide} from "ng-forward"; |
| 2 | 2 | import {ProfileService} from "../../../lib/ng-noosfero-api/http/profile.service"; |
| 3 | +import {ArticleService} from "../../../lib/ng-noosfero-api/http/article.service"; | |
| 3 | 4 | |
| 4 | 5 | @Component({ |
| 5 | 6 | selector: "content-viewer-actions", |
| 6 | 7 | templateUrl: "app/article/content-viewer/navbar-actions.html", |
| 7 | - providers: [provide('profileService', { useClass: ProfileService })] | |
| 8 | + providers: [ | |
| 9 | + provide('profileService', { useClass: ProfileService }), | |
| 3 |
|
|
| 3 | + | |
| 4 | + | |
| 5 | +describe("Article BasicEditor", () => { | |
| 6 | + | |
| 7 | + let $rootScope: ng.IRootScopeService; | |
| 8 | + let $q: ng.IQService; | |
| 9 | + let articleServiceMock: any; | |
| 10 | + let profileServiceMock: any; | |
| 11 | + let $state: any; | |
| 12 | + let $stateParams: any; | |
| 13 | + let profile = { id: 1 }; | |
| 14 | + let notification: any; | |
| 15 | + | |
| 16 | + | |
| 17 | + beforeEach(inject((_$rootScope_: ng.IRootScopeService, _$q_: ng.IQService) => { | |
| 18 | + $rootScope = _$rootScope_; | |
| 1 |
|
|
| 27 | + articleServiceMock = jasmine.createSpyObj("articleServiceMock", ["createInParent"]); | |
| 28 | + | |
| 29 | + let setCurrentProfileByIdentifierResponse = $q.defer(); | |
| 30 | + setCurrentProfileByIdentifierResponse.resolve(profile); | |
| 31 | + | |
| 32 | + let articleCreate = $q.defer(); | |
| 33 | + articleCreate.resolve({ data: { path: "path", profile: { identifier: "profile" } } }); | |
| 34 | + | |
| 35 | + profileServiceMock.setCurrentProfileByIdentifier = jasmine.createSpy("setCurrentProfileByIdentifier").and.returnValue(setCurrentProfileByIdentifierResponse.promise); | |
| 36 | + articleServiceMock.createInParent = jasmine.createSpy("createInParent").and.returnValue(articleCreate.promise); | |
| 37 | + }); | |
| 38 | + | |
| 39 | + it("create an article in the current profile when save", done => { | |
| 40 | + let component: BasicEditorComponent = new BasicEditorComponent(articleServiceMock, profileServiceMock, $state, notification, $stateParams); | |
| 41 | + component.save(); | |
| 42 | + $rootScope.$apply(); | |
| 2 |
|
|
| 36 | 36 | "comment.post.success.title": "Bom trabalho!", |
| 37 | 37 | "comment.post.success.message": "Comentário salvo com sucesso!", |
| 38 | 38 | "comment.reply": "responder", |
| 39 | + "article.actions.edit": "Editar", | |
| 2 |
|
|