-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add navbar UI & dependencies for testing angular (#47)
- Add navbar as a directive - Add mock controller - Improve and fix navbar issues from previous versions - Add top nav case for long names - Sanitize transaltions - Add font-awesome - Update README.md with font-awesome configuration - Add dependencies for testing angular - Add karma, jasmine and angular-mocks dependencies - Add karma configuration - Add karma coverage reporter - Add karma to travis CI - Add codecov.io to project - Update pre-push hook to run karma tests - Add navbar directive test
- Loading branch information
1 parent
88ff648
commit a0947b2
Showing
25 changed files
with
623 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,3 +123,5 @@ bower_components/ | |
dist/ | ||
.sass-cache/ | ||
.tmp/ | ||
|
||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
'use strict'; | ||
|
||
define(['paw'], function(paw) { | ||
paw.controller('BodyController', function($scope) { | ||
define(['paw', 'directives/navbar'], function(paw) { | ||
paw.controller('BodyController', ['$scope', function($scope) { | ||
this.bodyControllerText = 'bodyControllerText'; | ||
}); | ||
}]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
define(['paw'], function(paw) { | ||
paw.controller('NavbarController', ['$scope', function NavbarController($scope) { | ||
this.user = { | ||
'fullName': 'Matías Nicolás Comercio Vázquez asdasdasdasdasdasdasdasdadasdasdas', | ||
'profileUrl': '/users/1' | ||
}; | ||
}]) | ||
.directive('xnavbar', function() { | ||
return { | ||
restrict: 'E', | ||
templateUrl: '/views/navbar.html', | ||
controller: 'NavbarController', | ||
controllerAs: 'controller' | ||
}; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use strict'; | ||
|
||
define(['paw', 'angular-mocks', 'directives/navbar', 'navbar-template'], function() { | ||
beforeEach(module('paw')); | ||
|
||
describe('NavbarController', function() { | ||
var $controller; | ||
|
||
beforeEach(inject(function(_$controller_) { | ||
$controller = _$controller_; | ||
})); | ||
|
||
describe('controller.user', function() { | ||
var $scope, controller; | ||
// for now, hardcoded data (when API integration is ready ==> replace this) | ||
var user = { | ||
'fullName': 'Matías Nicolás Comercio Vázquez asdasdasdasdasdasdasdasdadasdasdas', | ||
'profileUrl': '/users/1' | ||
}; | ||
|
||
beforeEach(function() { | ||
$scope = {}; | ||
controller = $controller('NavbarController', {$scope: $scope}); | ||
}); | ||
|
||
it('correctly sets the user', function() { | ||
expect(controller.user).toEqual(user); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('NavbarDirective', function() { | ||
beforeEach(module('directive-templates')); | ||
|
||
var $compile, $rootScope, element, scope; | ||
|
||
beforeEach(inject(function(_$compile_, _$rootScope_) { | ||
$compile = _$compile_; | ||
$rootScope = _$rootScope_; | ||
})); | ||
|
||
beforeEach(function() { | ||
element = angular.element('<xnavbar></xnavbar>'); | ||
$compile(element)($rootScope); | ||
$rootScope.$digest(); | ||
}); | ||
|
||
it('contains the navbar brand', function() { | ||
expect(element.find('.navbar-brand')[0]).toBeDefined(); | ||
}); | ||
|
||
it('is defined', function() { | ||
expect(element.find('.top-nav')[0]).toBeDefined(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
'use strict'; | ||
|
||
var allTestFiles = []; | ||
var TEST_REGEXP = /(spec|test)\.js$/i; | ||
|
||
// Get a list of all the test files to include | ||
Object.keys(window.__karma__.files).forEach(function (file) { | ||
if (TEST_REGEXP.test(file)) { | ||
allTestFiles.push(file); | ||
} | ||
}); | ||
|
||
require.config({ | ||
// Karma serves files under /base, which is the basePath from your config file | ||
baseUrl: '/base/app/scripts', | ||
|
||
// this is from where requirejs will search dependencies, prepending the baseUrl to | ||
// the specified files | ||
paths: { | ||
'paw': 'paw', | ||
'routes': 'routes', | ||
'services/dependencyResolverFor': 'services/dependencyResolverFor', | ||
'i18n/i18nLoader': 'i18n/i18nLoader', | ||
'i18n/translations.es': 'i18n/translations.es', | ||
affix: '../../bower_components/bootstrap-sass-official/assets/javascripts/bootstrap/affix', | ||
alert: '../../bower_components/bootstrap-sass-official/assets/javascripts/bootstrap/alert', | ||
angular: '../../bower_components/angular/angular', | ||
'angular-route': '../../bower_components/angular-route/angular-route', | ||
'angular-translate': '../../bower_components/angular-translate/angular-translate', | ||
'angular-mocks': '../../bower_components/angular-mocks/angular-mocks', | ||
button: '../../bower_components/bootstrap-sass-official/assets/javascripts/bootstrap/button', | ||
bootstrap: '../../bower_components/bootstrap/dist/js/bootstrap', | ||
carousel: '../../bower_components/bootstrap-sass-official/assets/javascripts/bootstrap/carousel', | ||
collapse: '../../bower_components/bootstrap-sass-official/assets/javascripts/bootstrap/collapse', | ||
dropdown: '../../bower_components/bootstrap-sass-official/assets/javascripts/bootstrap/dropdown', | ||
'es5-shim': '../../bower_components/es5-shim/es5-shim', | ||
jquery: '../../bower_components/jquery/dist/jquery', | ||
json3: '../../bower_components/json3/lib/json3', | ||
modal: '../../bower_components/bootstrap-sass-official/assets/javascripts/bootstrap/modal', | ||
moment: '../../bower_components/moment/moment', | ||
popover: '../../bower_components/bootstrap-sass-official/assets/javascripts/bootstrap/popover', | ||
requirejs: '../../bower_components/requirejs/require', | ||
scrollspy: '../../bower_components/bootstrap-sass-official/assets/javascripts/bootstrap/scrollspy', | ||
tab: '../../bower_components/bootstrap-sass-official/assets/javascripts/bootstrap/tab', | ||
tooltip: '../../bower_components/bootstrap-sass-official/assets/javascripts/bootstrap/tooltip', | ||
transition: '../../bower_components/bootstrap-sass-official/assets/javascripts/bootstrap/transition', | ||
'font-awesome': '../../bower_components/font-awesome', | ||
'bootstrap-sass-official': '../../bower_components/bootstrap-sass-official/assets/javascripts/bootstrap', | ||
'navbar-template': '../views/navbar.html' | ||
}, | ||
shim: { | ||
angular: { | ||
deps: [ | ||
'jquery' | ||
] | ||
}, | ||
'angular-route': { | ||
deps: [ | ||
'angular' | ||
] | ||
}, | ||
'angular-mocks': { | ||
deps: [ | ||
'angular' | ||
] | ||
}, | ||
bootstrap: { | ||
deps: [ | ||
'jquery', | ||
'modal' | ||
] | ||
}, | ||
modal: { | ||
deps: [ | ||
'jquery' | ||
] | ||
}, | ||
tooltip: { | ||
deps: [ | ||
'jquery' | ||
] | ||
}, | ||
'angular-translate': { | ||
deps: [ | ||
'angular' | ||
] | ||
}, | ||
// all directives templates should be declared as follows | ||
'navbar-template': { | ||
deps: [ | ||
'angular' | ||
] | ||
} | ||
}, | ||
packages: [ | ||
|
||
], | ||
|
||
// dynamically load all test files | ||
deps: allTestFiles, | ||
|
||
// we have to kickoff jasmine, as it is asynchronous | ||
callback: function() { | ||
console.log('load complete'); | ||
window.__karma__.start(); | ||
} | ||
}); |
Oops, something went wrong.