Skip to content
This repository has been archived by the owner on Jul 30, 2019. It is now read-only.

Commit

Permalink
Merge pull request #659 from 18F/jy-jasmine-2
Browse files Browse the repository at this point in the history
Add Jasmine:CI to default rake task
  • Loading branch information
jessieay committed Jun 3, 2016
2 parents ebe2461 + b248088 commit 8e56d82
Show file tree
Hide file tree
Showing 8 changed files with 422 additions and 395 deletions.
2 changes: 2 additions & 0 deletions Rakefile
Expand Up @@ -9,3 +9,5 @@ if Rails.env.development?
end

Rails.application.load_tasks

task default: 'jasmine:ci'
29 changes: 18 additions & 11 deletions app/assets/javascripts/utility.js
@@ -1,9 +1,9 @@
'use strict';

(function (window) {
var microp = {};
var microp = {};

/**
/**
* 'throttles' the execution of a funtion.
* will only call the function passed to throttle
* once every @threshold milliseconds
Expand Down Expand Up @@ -45,19 +45,23 @@
};
};

microp.format.stardardizeUrl = function(str) {
var lastChar = str.length - 1;
if (str.charAt(lastChar) === '/') {
str = str.substring(0, lastChar);
microp.format.standardizeUrl = function(str) {
if (typeof(str) === 'string'){
var lastChar = str.length - 1;

if (str.charAt(lastChar) === '/') {
str = str.substring(0, lastChar);
}
str = str.toLowerCase();
}
str = str.toLowerCase();
return str;
};

microp.format.removeGitPrefix = function(str) {
return str.includes('https')
? str.split("https://github.com/").join("")
: str;
if (typeof(str) === 'string'){
str = str.split("https://github.com/").join("");
}
return str;
};

microp.format.transformDollars = function(str) {
Expand All @@ -78,6 +82,10 @@
// Outputs a date object formatted like so: %Y-%m-%d
// Or like so %m/%d if a separator is included
microp.format.date = function (date, seperator) {
if (typeof(date) === 'undefined' || typeof(date) === undefined) {
return date;
}

var dateObj,
date;
if (typeof(date) === 'string') {
Expand All @@ -100,5 +108,4 @@
};

window.microp = microp;

})(this);
4 changes: 2 additions & 2 deletions app/assets/javascripts/winners/charts.js
Expand Up @@ -278,7 +278,7 @@
settings.x = 'date_community';

_.each(auctions, function(auction){
auction.github_repo = microp.format.stardardizeUrl(auction.github_repo);
auction.github_repo = microp.format.standardizeUrl(auction.github_repo);
auction.github_repo = microp.format.removeGitPrefix(auction.github_repo);
})

Expand Down Expand Up @@ -363,7 +363,7 @@
settings.cols = [];

_.each(auctions, function(auction){
auction.github_repo = microp.format.stardardizeUrl(auction.github_repo);
auction.github_repo = microp.format.standardizeUrl(auction.github_repo);
auction.github_repo = microp.format.removeGitPrefix(auction.github_repo);
})

Expand Down
10 changes: 7 additions & 3 deletions app/assets/javascripts/winners/metrics.js
Expand Up @@ -67,8 +67,12 @@

getBidsPerAuction: function() {
var bidsPerAuction = _.map(this.auctions, function(auction, key){
return auction.bids.length
})
if (auction.bids) {
return auction.bids.length
} else {
return 0;
}
});
return d3.mean(bidsPerAuction);
},

Expand All @@ -83,7 +87,7 @@
getUniqueRepos: function getUniqueRepos() {
var repos = _.pluck(this.auctions, 'github_repo')
repos = _.map(repos, function(value,key) {
return microp.format.stardardizeUrl(value);
return microp.format.standardizeUrl(value);
})
repos = _.uniq(repos).length;
return repos;
Expand Down
32 changes: 16 additions & 16 deletions spec/javascripts/drawer_spec.js
@@ -1,95 +1,95 @@
describe('Drawer', function () {
var drawer

describe('When you first see the page', function () {
describe('When you first go to the homepage, the drawer', function () {
beforeEach(function () {
drawer = new Drawer();
});

it('then the drawer is hidden', function() {
it('is hidden', function() {
expect(drawer.isOpen).not.toBeTruthy();
});
});

describe('When show is triggered', function () {
describe('When show is triggered, the drawer', function () {
beforeEach(function () {
drawer = new Drawer();
drawer.show()
});

it('then the drawer is open', function() {
it('is open', function() {
expect(drawer.isOpen).toBeTruthy();
});
});

describe('When show is triggered twice', function () {
describe('When show is triggered twice, the drawer', function () {
beforeEach(function () {
drawer = new Drawer();
drawer.show();
drawer.show();
});

it('then the drawer is open', function() {
it('is open', function() {
expect(drawer.isOpen).toBeTruthy();
});
});

describe('When hide is triggered twice', function () {
describe('When hide is triggered twice, the drawer', function () {
beforeEach(function () {
drawer = new Drawer();
drawer.hide();
drawer.hide();
});

it('then the drawer is closed', function() {
it('is closed', function() {
expect(drawer.isOpen).not.toBeTruthy();
});
});

describe('When the drawer is toggled', function () {
describe('When the drawer is toggled, the drawer', function () {
beforeEach(function () {
drawer = new Drawer();
drawer.toggle();
})

it('then it opens', function() {
it('is open', function() {
expect(drawer.isOpen).toBeTruthy();
})
});

describe('When the drawer is opened, then closed', function () {
describe('When the drawer is opened, then closed, the drawer', function () {
beforeEach(function () {
drawer = new Drawer();
drawer.show();
drawer.hide();
})

it('then it is closed', function() {
it('is closed', function() {
expect(drawer.isOpen).not.toBeTruthy()
});
});

describe('When the drawer is toggled twice', function () {
describe('When the drawer is toggled twice, the drawer', function () {
beforeEach(function () {
drawer = new Drawer();
drawer.toggle();
drawer.toggle();
})

it('then it is closed', function() {
it('is closed', function() {
expect(drawer.isOpen).not.toBeTruthy();
});
});

describe('When the drawer is toggled three times', function () {
describe('When the drawer is toggled three times, the drawer', function () {
beforeEach(function () {
drawer = new Drawer();
drawer.toggle();
drawer.toggle();
drawer.toggle();
})

it('then it is open', function() {
it('is open', function() {
expect(drawer.isOpen).toBeTruthy();
})
});
Expand Down

0 comments on commit 8e56d82

Please sign in to comment.