Skip to content

Commit

Permalink
Added test for the post edit state, could not add test for watcher as…
Browse files Browse the repository at this point in the history
… it doesn't seem to fire with a $scope.$apply().
  • Loading branch information
zakhenry committed Aug 28, 2015
1 parent fb2434a commit eed665b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
4 changes: 3 additions & 1 deletion api/app/Services/ModelFactoryInstance.php
Expand Up @@ -2,6 +2,7 @@

namespace App\Services;

use Illuminate\Database\Eloquent\FactoryBuilder;
use Illuminate\Support\Collection;
use App\Http\Transformers\BaseTransformer;
use App\Http\Transformers\EloquentModelTransformer;
Expand All @@ -11,6 +12,7 @@
class ModelFactoryInstance implements Arrayable, Jsonable
{
private $transformerService;
/** @var FactoryBuilder */
private $factoryInstance;
private $customizations = [];
private $entityCount = 1;
Expand All @@ -27,7 +29,7 @@ class ModelFactoryInstance implements Arrayable, Jsonable
* @param $factoryInstance
* @param $transformerService
*/
public function __construct($factoryInstance, $transformerService)
public function __construct(FactoryBuilder $factoryInstance, $transformerService)
{
$this->factoryInstance = $factoryInstance;
$this->transformerService = $transformerService;
Expand Down
2 changes: 1 addition & 1 deletion app/src/app/admin/articles/article/article.spec.ts
Expand Up @@ -23,7 +23,7 @@ namespace app.admin.articles.article {
newArticle:true
},
articleService = {
saveArticleWithRelated:(article:common.models.Article, newArticle:boolean = false) => {
saveArticleWithRelated:(article:common.models.Article) => {
return $q.when(true);
}
},
Expand Down
53 changes: 53 additions & 0 deletions app/src/app/admin/articles/article/post/post.spec.ts
@@ -0,0 +1,53 @@
namespace app.admin.articles.article.post {

describe('Post Editing', () => {

let article:common.models.Article,
$scope:ng.IScope,
$rootScope:ng.IRootScopeService,
PostController:PostController;

beforeEach(() => {

article = new common.models.Article({
_tags: [
new common.models.Tag({
tag: 'existing'
}, true)
]
}, true);

module('app');

inject(($controller, _$rootScope_, _tagService_) => {
$rootScope = _$rootScope_;
$scope = $rootScope.$new();

PostController = $controller(app.admin.articles.article.post.namespace + '.controller', {
article: article,
tagService: _tagService_,
$scope: $scope,
});


});


});


it('should be able to define tags as an array, and they should be transformed to a collection', () => {

PostController.article = article;

PostController.tags = ['newTag', 'anotherNewTag', 'existing'];

PostController.updateArticleTags();

expect(PostController.article._tags).to.have.lengthOf(3);

});

});

}
2 changes: 1 addition & 1 deletion app/src/app/admin/articles/article/post/post.ts
Expand Up @@ -7,7 +7,7 @@ namespace app.admin.articles.article.post {
public tags:string[];

static $inject = ['article', 'tagService', '$scope'];
constructor(public article:common.models.Article, private tagService:common.services.tag.TagService, private $scope:ng.IScope) {
constructor(public article:common.models.Article, private tagService:common.services.tag.TagService, public $scope:ng.IScope) {


this.tags = _.pluck(article._tags, 'tag');
Expand Down

0 comments on commit eed665b

Please sign in to comment.