Skip to content

Commit

Permalink
tests and more improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorMinar committed May 8, 2012
1 parent 3c5cdb2 commit eb0b6e5
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 76 deletions.
4 changes: 4 additions & 0 deletions app/css/app.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* app css stylesheet */

div {
font-size: 30px;
}

.menu {
list-style: none;
border-bottom: 0.1em solid black;
Expand Down
5 changes: 4 additions & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
<body ng-controller="GameCtrl">
<div>Pairs left to match: {{game.unmatchedPairs}}</div>
<div>Matching: {{game.firstPick.title}}</div>

<table>
<tr ng-repeat="row in game.grid">
<td ng-repeat="tile in row">
<div ng-click="game.flipTile(tile)"><img ng-src="img/{{tile.imgName()}}.png"</div>
<div ng-click="game.flipTile(tile)">
<img ng-src="img/{{tile.imgName()}}.png">
</div>
</td>
</tr>
</table>
Expand Down
36 changes: 36 additions & 0 deletions test/unit/appSpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* jasmine specs for controllers go here */

describe('MemoryGameApp', function() {

beforeEach(module('memoryGameApp'));


describe('GameCtrl', function(){
var gameCtrl, scope;

beforeEach(inject(function($controller, $rootScope){
scope = $rootScope.$new();
gameCtrl = $controller('GameCtrl', {$scope: scope});
}));


it('should publish the game model', function() {
expect(scope.game).toBeDefined();
});
});


describe('game', function(){
var game;


beforeEach(inject(function(_game_){
game = _game_;
}));


it('should create a game with 8 tile pairs', function() {
expect(game.unmatchedPairs).toBe(8);
});
});
});
29 changes: 0 additions & 29 deletions test/unit/controllersSpec.js

This file was deleted.

17 changes: 0 additions & 17 deletions test/unit/directivesSpec.js

This file was deleted.

17 changes: 0 additions & 17 deletions test/unit/filtersSpec.js

This file was deleted.

42 changes: 42 additions & 0 deletions test/unit/gameSpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
describe('Game', function() {

var tileNames = ['turtle', 'hammer'],
game;

beforeEach(function() {
game = new Game(tileNames);
});


describe('init', function() {
it('should create a 2x2 grid', function() {
expect(game.grid.length).toBe(2);
expect(game.grid[0].length).toBe(2);
expect(game.grid[1].length).toBe(2);
});


it('should initialize unmatchedPairs and message', function() {
expect(game.message).toBe('Click on a tile.');
expect(game.unmatchedPairs).toBe(2);
});
});


describe('flip', function() {
it('should set the flipped flag on the tile being flipped', function() {
var tile = game.grid[0][0];
expect(tile.flipped).toBe(false);
game.flipTile(tile);
expect(tile.flipped).toBe(true);
});

it('should update the image name when a tile is flipped', function() {
var tile = game.grid[0][0];
expect(tile.imgName()).toBe('back');

game.flipTile(tile);
expect(tile.imgName()).not.toBe('back');
});
});
});
12 changes: 0 additions & 12 deletions test/unit/servicesSpec.js

This file was deleted.

0 comments on commit eb0b6e5

Please sign in to comment.