Skip to content
This repository was archived by the owner on Nov 29, 2022. It is now read-only.

Commit 3d1e44b

Browse files
committed
updated unit tests
1 parent 7fbee60 commit 3d1e44b

File tree

4 files changed

+21
-30
lines changed

4 files changed

+21
-30
lines changed

karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ module.exports = function(config) {
7979
// optionally, configure the reporter
8080
coverageReporter: {
8181
type : 'html',
82-
dir : 'test/coverage/'
82+
dir : 'dist/coverage/'
8383
},
8484

8585
ngHtml2JsPreprocessor: {

src/client/app/components/deckLoader/deckLoader.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ rootApp.directive("deckLoader", function () {
44
templateUrl: "components/deckLoader/deckLoader.html",
55
scope: {},
66
controller: function ($scope, decks, users ) {
7-
console.log(decks);
87
$scope.Decks = decks;
98

109
if(users.user_id){

src/client/app/components/deckLoader/deckLoader.spec.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,29 @@ describe('deckLoader.js', function(){
55
$scope,
66
$element,
77
$q,
8-
mockDecks = function(){
9-
this.get = function(){};
10-
};
8+
decks;
119

1210
beforeEach(module('app'));
1311
beforeEach(module('app.templates'));
1412
beforeEach(module(function($provide) {
15-
//decks calls Webdecks, Webdecks makes a HTTP request, Fake it.
16-
$provide.value("decks", new mockDecks());
13+
$provide.service("decks", function(){
14+
this.get = function(){
15+
return $q.when('mockDecks');
16+
};
17+
});
1718
}));
18-
beforeEach(inject(function(_$compile_, _$rootScope_, _$q_){
19+
beforeEach(inject(function(_$compile_, _$rootScope_, _$q_, _decks_){
1920
$compile = _$compile_;
2021
$rootScope = _$rootScope_;
2122
$q = _$q_;
23+
decks = _decks_;
2224
}));
2325
beforeEach(function(){
2426
var element = $compile("<deck-loader></deck-loader>")($rootScope);
2527
$rootScope.$digest();
2628
$scope = element.isolateScope() || element.scope();
2729
});
2830
it('should bind the decks service to $scope', function() {
29-
console.log($scope);
30-
//expect($scope.Decks).toEqual("decks");
31+
expect($scope.Decks).toEqual(decks);
3132
});
3233
});

src/client/app/components/pokemonCard/pokemonCard.spec.js

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,23 @@ describe('pokemonCard.js', function(){
33
var $compile,
44
$rootScope,
55
$scope,
6-
$element;
7-
8-
var cardsSeriveMock = {
9-
get : jasmine.createSpy('get'),
10-
typeof : jasmine.createSpy('typeof')
11-
};
12-
13-
var decksSeriveMock = {
14-
get : jasmine.createSpy('get'),
15-
};
6+
$element,
7+
cards;
168

179
beforeEach(module('app'));
1810
beforeEach(module('app.templates'));
1911
beforeEach(module(function($provide) {
20-
//$provide.value("markedCards", "markedCards" );
21-
//$provide.value("activeCard", "activeCard" );
22-
$provide.value("cards", cardsSeriveMock);
23-
$provide.value("decks", decksSeriveMock );
24-
//$provide.value("typeChecker", "typeChecker");
12+
$provide.service("cards", function($q){
13+
this.getById = jasmine.createSpy('getById').and.callFake(function(num) {
14+
return $q.when("ABC");
15+
});
16+
});
17+
2518
}));
26-
beforeEach(inject(function(_$compile_, _$rootScope_){
19+
beforeEach(inject(function(_$compile_, _$rootScope_, _cards_, _decks_){
2720
$compile = _$compile_;
2821
$rootScope = _$rootScope_;
22+
cards = _cards_;
2923
}));
3024

3125

@@ -39,8 +33,6 @@ describe('pokemonCard.js', function(){
3933
expect($scope.card.name).toEqual('mock');
4034

4135
});
42-
43-
4436
});
4537

4638
describe('When card data is absent in the directive',function(){
@@ -50,8 +42,7 @@ describe('pokemonCard.js', function(){
5042
$scope = element.isolateScope() || element.scope();
5143
});
5244
it('should bind the decks service to $scope', function() {
53-
54-
expect(cardsSeriveMock.get ).toHaveBeenCalledWith({id:55});
45+
expect(cards.getById ).toHaveBeenCalledWith(55);
5546
});
5647
});
5748

0 commit comments

Comments
 (0)