replaced Chrome browser with PhantomJS in karma tests

moved header to parent page, removed from templates
This commit is contained in:
Brad Rydzewski 2014-06-21 19:40:21 -07:00
parent 18f7209d1d
commit 77daa5743f
17 changed files with 2191 additions and 62 deletions

View file

@ -8,6 +8,7 @@ deps:
# npm -g install karma
# npm -g install karma-jasmine
# npm -g install karma-chrome-launcher
# npm -g install karma-phantomjs-launcher
go get github.com/GeertJohan/go.rice/rice
go list github.com/drone/drone/... | xargs go get -t -v

View file

@ -14,9 +14,7 @@
</head>
<body ng-controller="MainCtrl">
<h1>
{{ user }}
</h1>
<div ng-include src=" '/views/header.html' "></div>
<div ng-view></div>

View file

@ -16,6 +16,7 @@ module.exports = function(config) {
// list of files / patterns to load in the browser
files: [
'scripts/vendor/angular.min.js',
'scripts/vendor/angular-mocks.js',
'scripts/app.js',
'scripts/*/*.js',
'scripts/*/*.spec.js'
@ -60,7 +61,7 @@ module.exports = function(config) {
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
browsers: ['PhantomJS'],
// Continuous Integration mode

View file

@ -1,5 +1,13 @@
'use strict';
angular.module('app').controller("MainCtrl", function($scope, $http) {
$scope.user = "soemthing"
angular.module('app').controller("MainCtrl", function($scope, $http, users) {
$scope.state=0
$scope.user = users.getCurrent().success(function (user) {
$scope.user = user;
$scope.state = 1;
})
.error(function (error) {
$scope.user = undefined;
$scope.state = 1;
});
});

View file

@ -1,7 +1,39 @@
'use strict';
describe('users controller', function(){
it('should 1==1', function(){
expect(1).toBe(1)
var $controller, createController, $scope, httpBackend;
$scope = {};
beforeEach(module('app'));
beforeEach(inject(function (_$controller_, $httpBackend) {
$controller = _$controller_;
httpBackend = $httpBackend;
}));
createController = function () {
return $controller('UsersController', {
'$scope': $scope,
'user': {}
});
};
afterEach(function () {
httpBackend.verifyNoOutstandingRequest();
httpBackend.verifyNoOutstandingExpectation();
});
it('should get the list of users', function(){
var controller, users;
users = [
'brad',
'nathan',
'solomon'
];
$scope.users = [];
httpBackend.whenGET('/v1/users').respond(200, users);
controller = createController();
httpBackend.flush();
expect($scope.users).toEqual(users);
});
});

View file

@ -1,31 +1,7 @@
'use strict';
angular.module('app').service('userService', function($q, $http, $timeout) {
return{
user : null,
getCurrent : function() {
var _this = this;
var defer = $q.defer();
// if the user is already authenticated
if (_this.user != null) {
defer.resolve(_this.user);
}
// else we need to fetch from the server
$http({method: 'GET', url: '/v1/user'}).
then(function(data) {
_this.user=data;
defer.resolve(_this.user);
}).
error(function(data, status) {
_this.user=null;
defer.resolve();
});
// returns a promise that this will complete
// at some future time.
return defer.promise;
}
}
});
angular.module('app').service('users', ['$http', function($http) {
this.getCurrent = function() {
return $http.get('/v1/user');
};
}]);

2136
server/app/scripts/vendor/angular-mocks.js vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,3 @@
<div ng-include src=" '/views/header.html' "></div>
<h1>User Account</h1>
<div class="row">

View file

@ -1,6 +1,3 @@
<div ng-include src=" '/views/header.html' "></div>
<h1>{{ repo.name }}</h1>
<a href="/{{ repo.remote }}/{{ repo.owner}}/{{ repo.name }}">Back</a>
<a href="/{{ repo.remote }}/{{ repo.owner}}/{{ repo.name }}/settings">Settings</a>

View file

@ -1,6 +1,3 @@
<div ng-include src=" '/views/header.html' "></div>
<h1>{{ repo.name }}</h1>
<a href="/{{ repo.remote }}/{{ repo.owner}}/{{ repo.name }}">Back</a>
<a href="/{{ repo.remote }}/{{ repo.owner}}/{{ repo.name }}/settings">Settings</a>

View file

@ -1,10 +1,10 @@
<table border="1">
<tr ng-if="user != null">
<tr ng-if="user != undefined">
<td><a href="/">Home</a></td>
<td><a href="/account/profile">{{ user.login }}</a></td>
<td><img ng-src="{{ user.gravatar | gravatar }}" /></td>
</tr>
<tr ng-if="user == null">
<tr ng-if="user == undefined">
<td>
<a href="/login">Login</a>
</td>

View file

@ -1,5 +1,3 @@
<div ng-include src=" '/views/header.html' "></div>
<h1>Dashboard</h1>
<div class="row">

View file

@ -1,5 +1,3 @@
<div ng-include src=" '/views/header.html' "></div>
<h1>Login</h1>
<div class="pure-u-1">

View file

@ -1,6 +1,3 @@
<div ng-include src=" '/views/header.html' "></div>
<h1>{{ repo.name }}</h1>

View file

@ -1,6 +1,3 @@
<div ng-include src=" '/views/header.html' "></div>
<h1>{{ repo.name }}</h1>
<h2>Config</h2>

View file

@ -1,6 +1,3 @@
<div ng-include src=" '/views/header.html' "></div>
<div class="row">
<div class="col-xs-6 col-sm-3">
<ul>

View file

@ -1,5 +1,3 @@
<div ng-include src=" '/views/header.html' "></div>
<div class="row">
<div class="col-xs-6 col-sm-3">
<ul>