Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Get the tests running with phantomjs using npm test

  • Loading branch information...
commit 58d99d9e228d90c1031dbe022150f0470b6c71d8 1 parent df404f5
Tomas Doran bobtfish authored
3  .gitignore
View
@@ -0,0 +1,3 @@
+*.swp
+node_modules/
+
4 .travis.yml
View
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - 0.8
+
5 app/js/controllers.js
View
@@ -41,13 +41,14 @@ function ReportDetailCtrl($scope, $routeParams, $http) {
function addContextTo(data) {
data.iconFailures = "icon-ok";
data.iconChanges = "icon-minus";
- if (data.fields.metrics.resources.Failed > 0) {
+ if (data.fields.metrics.resources.Failed > 0) {
data.hadFailures = "hadFailures";
data.iconFailures = "icon-remove";
}
- if (!data.fields.metrics.events.Noop || data.fields.metrics.events.Noop < 1) {
+ if (!data.fields.metrics.events.Noop || data.fields.metrics.events.Noop < 1) {
data.hadChanges = "hadChanges";
data.iconChanges = "icon-exclamation-sign";
}
return data;
}
+
23 package.json
View
@@ -0,0 +1,23 @@
+{
+ "name": "norman",
+ "version": "0.0.0",
+ "description": "A Puppet run reports viewer for reports stored in Elasticsearch",
+ "main": "index.js",
+ "directories": {
+ "test": "test"
+ },
+ "scripts": {
+ "test": "./node_modules/.bin/testacular start --single-run --browsers PhantomJS config/testacular.conf.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/youdevise/norman.git"
+ },
+ "author": "Tomas Doran",
+ "license": "BSD",
+ "readmeFilename": "README.md",
+ "gitHead": "df404f5735ddb330bfea6b41fae17a12bf3cd1c7",
+ "devDependencies": {
+ "testacular": "~0.6"
+ }
+}
13 scripts/update-repo.sh
View
@@ -1,13 +0,0 @@
-#!/bin/bash
-
-###
-# This scripts updates the local repo with the latest changes from github.
-#
-# The master branch will be REPLACED with what's in github and all local changes
-# will be LOST.
-###
-
-git checkout master
-git fetch -f origin
-git fetch --tags origin
-git reset --hard origin/master
67 test/unit/controllersSpec.js
View
@@ -1,32 +1,79 @@
'use strict';
/* jasmine specs for controllers go here */
-describe('PhoneCat controllers', function() {
+describe('Norman controllers', function() {
+
+ var all_reports = [
+ {
+ '@uuid': 'FOO1',
+ '@fields': {
+ 'metrics': {
+ 'resources': {
+ 'Failed': 0
+ },
+ 'events': {
+ 'Noop': 0
+ }
+ }
+ }
+ },
+ {
+ '@uuid': 'FOO2',
+ '@fields': {
+ 'metrics': {
+ 'resources': {
+ 'Failed': 0
+ },
+ 'events': {
+ 'Noop': 0
+ }
+ }
+ }
+ }
+ ];
+
+ var all_reports_cleaned = [];
+ all_reports.forEach(function (report) {
+ var n = angular.fromJson(angular.toJson(report));
+ n['uuid'] = n['@uuid'];
+ n['fields'] = n['@fields'];
+ delete(n['@uuid']);
+ delete(n['@fields']);
+ n['iconFailures'] = 'icon-ok';
+ n['iconChanges'] = 'icon-exclamation-sign';
+ n['hadChanges'] = 'hadChanges';
+ all_reports_cleaned.push(n);
+ });
describe('ReportListCtrl', function(){
var scope, ctrl, $httpBackend;
beforeEach(inject(function(_$httpBackend_, $rootScope, $controller) {
$httpBackend = _$httpBackend_;
+// $httpBackend.expectPOST('/add-msg.py', 'message content').respond(201, '');
$httpBackend.expectGET('data/reports_latest.json').
- respond([{uuid: 'FOO1'}, {uuid: 'FOO2'}]);
+ respond(all_reports);
scope = $rootScope.$new();
ctrl = $controller(ReportListCtrl, {$scope: scope});
}));
+ afterEach(function() {
+ $httpBackend.verifyNoOutstandingExpectation();
+ $httpBackend.verifyNoOutstandingRequest();
+ });
it('should create "reports" model with 2 reports fetched from xhr', function() {
expect(scope.reports).toBeUndefined();
$httpBackend.flush();
- expect(scope.reports).toEqual([{uuid: 'FOO1'},
- {uuid: 'FOO2'}]);
+ expect(scope.reports).toEqual(all_reports_cleaned);
});
it('should set the default value of orderProp model', function() {
- expect(scope.orderProp).toBe('age');
+ $httpBackend.flush();
+ expect(scope.orderProp).toBe('-timestamp');
});
});
@@ -34,7 +81,7 @@ describe('PhoneCat controllers', function() {
describe('ReportDetailCtrl', function(){
var scope, ctrl, $httpBackend;
- var report = {uuid: 'FOO1', 'fields': { 'logs': [ 'line1', 'line2' ]} };
+ var report = all_reports[0]
beforeEach(inject(function(_$httpBackend_, $rootScope, $routeParams, $controller) {
$httpBackend = _$httpBackend_;
@@ -47,10 +94,16 @@ describe('PhoneCat controllers', function() {
ctrl = $controller(ReportDetailCtrl, {$scope: scope});
}));
+ afterEach(function() {
+ $httpBackend.verifyNoOutstandingExpectation();
+ $httpBackend.verifyNoOutstandingRequest();
+ });
+
it('should create "report" model with log lines in fields', function() {
expect(scope.report).toBeUndefined();
$httpBackend.flush();
- expect(scope.report).toEqual(report);
+ expect(scope.report).toEqual(all_reports_cleaned[0]);
})
});
});
+
Please sign in to comment.
Something went wrong with that request. Please try again.