From 229f514819f7249258466c097f323b6ef00afd0e Mon Sep 17 00:00:00 2001 From: Mario Basic Date: Sun, 14 Jun 2015 00:31:22 +0200 Subject: [PATCH] Started working on getting the time logged today. --- assets/js/config.js | 2 ++ assets/js/helpers/getTodaysDateInFormat.js | 13 ++++++++++++ package.json | 14 ++++++------- public/js/bundle.js | 2 ++ public/js/events.js | 2 ++ public/js/options.js | 2 ++ tests/components/MainList.react.jest.js | 22 ++++++++++----------- tests/components/Navbar.react.jest.js | 22 ++++++++++----------- tests/components/Wakatime.react.jest.js | 22 ++++++++++----------- tests/helpers/changeExtensionIcon.spec.js | 8 ++++---- tests/helpers/currentTimestamp.spec.js | 8 ++++---- tests/helpers/getTodaysDateInFormat.spec.js | 14 +++++++++++++ 12 files changed, 83 insertions(+), 48 deletions(-) create mode 100644 assets/js/helpers/getTodaysDateInFormat.js create mode 100644 tests/helpers/getTodaysDateInFormat.spec.js diff --git a/assets/js/config.js b/assets/js/config.js index bacc4f0..7e16dba 100644 --- a/assets/js/config.js +++ b/assets/js/config.js @@ -15,6 +15,8 @@ var config = { currentUserApiUrl: 'https://wakatime.com/api/v1/users/current', // The url to logout the user from wakatime logoutUserUrl: 'https://wakatime.com/logout', + // Gets stats from the WakaTime API + summariesApiUrl: 'https://wakatime.com/api/v1/users/current/summaries', // Different colors for different states of the extension colors: { allGood: '', diff --git a/assets/js/helpers/getTodaysDateInFormat.js b/assets/js/helpers/getTodaysDateInFormat.js new file mode 100644 index 0000000..0575a88 --- /dev/null +++ b/assets/js/helpers/getTodaysDateInFormat.js @@ -0,0 +1,13 @@ +function getTodaysDateInFormat() +{ + var today = new Date(); + var month = today.getMonth() + 1; + var date = today.getDate(); + + if(month < 10) month = '0' + month; + if(date < 10) date = '0' + date; + + return today.getFullYear() + '-' + month + '-' + date; +} + +export default getTodaysDateInFormat; \ No newline at end of file diff --git a/package.json b/package.json index 02ef01f..664bf81 100644 --- a/package.json +++ b/package.json @@ -15,21 +15,21 @@ }, "private": true, "devDependencies": { - "babel-jest": "^5.2.0", - "chai": "^3.0.0", + "babel-jest": "^5.3.0", "gulp": "^3.8.8", - "jest-cli": "^0.4.10", - "babel": "^5.5.6", + "jest-cli": "^0.4.12", "laravel-elixir": "*", + "react-tools": "^0.13.3", "mocha": "^2.2.5", "mocha-sinon": "^1.1.4", "mocha-traceur": "^2.1.0", - "sinon": "^1.14.1" + "sinon": "^1.14.1", + "babel": "^5.5.6", + "chai": "^3.0.0" }, "dependencies": { "bootstrap": "^3.3.4", "jquery": "^2.1.3", - "react": "^0.13.3", - "react-tools": "^0.13.3" + "react": "^0.13.3" } } diff --git a/public/js/bundle.js b/public/js/bundle.js index b690da7..9bcd9b2 100644 --- a/public/js/bundle.js +++ b/public/js/bundle.js @@ -530,6 +530,8 @@ var config = { currentUserApiUrl: 'https://wakatime.com/api/v1/users/current', // The url to logout the user from wakatime logoutUserUrl: 'https://wakatime.com/logout', + // Gets stats from the WakaTime API + summariesApiUrl: 'https://wakatime.com/api/v1/users/current/summaries', // Different colors for different states of the extension colors: { allGood: '', diff --git a/public/js/events.js b/public/js/events.js index 1f285e3..a5f7599 100644 --- a/public/js/events.js +++ b/public/js/events.js @@ -119,6 +119,8 @@ var config = { currentUserApiUrl: 'https://wakatime.com/api/v1/users/current', // The url to logout the user from wakatime logoutUserUrl: 'https://wakatime.com/logout', + // Gets stats from the WakaTime API + summariesApiUrl: 'https://wakatime.com/api/v1/users/current/summaries', // Different colors for different states of the extension colors: { allGood: '', diff --git a/public/js/options.js b/public/js/options.js index 2e4da5c..1d08a18 100644 --- a/public/js/options.js +++ b/public/js/options.js @@ -89,6 +89,8 @@ var config = { currentUserApiUrl: 'https://wakatime.com/api/v1/users/current', // The url to logout the user from wakatime logoutUserUrl: 'https://wakatime.com/logout', + // Gets stats from the WakaTime API + summariesApiUrl: 'https://wakatime.com/api/v1/users/current/summaries', // Different colors for different states of the extension colors: { allGood: '', diff --git a/tests/components/MainList.react.jest.js b/tests/components/MainList.react.jest.js index 8ae0d98..0e4fd62 100644 --- a/tests/components/MainList.react.jest.js +++ b/tests/components/MainList.react.jest.js @@ -1,17 +1,17 @@ jest.dontMock('../../assets/js/components/MainList.react.js'); describe('MainList', function() { - var React, MainList, TestUtils, Component; + var React, MainList, TestUtils, Component; - beforeEach(function() { - // Setup our tools - React = require('react/addons'); - MainList = require('../../assets/js/components/MainList.react.js'); - TestUtils = React.addons.TestUtils; - // Create the React component here using TestUtils and store into Component - }); + beforeEach(function() { + // Setup our tools + React = require('react/addons'); + MainList = require('../../assets/js/components/MainList.react.js'); + TestUtils = React.addons.TestUtils; + // Create the React component here using TestUtils and store into Component + }); - it('should work', function() { - expect(2 + 2).toEqual(4); - }); + it('should work', function() { + expect(2 + 2).toEqual(4); + }); }); \ No newline at end of file diff --git a/tests/components/Navbar.react.jest.js b/tests/components/Navbar.react.jest.js index 9e8ff1f..c809a1c 100644 --- a/tests/components/Navbar.react.jest.js +++ b/tests/components/Navbar.react.jest.js @@ -1,17 +1,17 @@ jest.dontMock('../../assets/js/components/Navbar.react.js'); describe('Navbar', function() { - var React, Navbar, TestUtils, Component; + var React, Navbar, TestUtils, Component; - beforeEach(function() { - // Setup our tools - React = require('react/addons'); - Navbar = require('../../assets/js/components/Navbar.react.js'); - TestUtils = React.addons.TestUtils; - // Create the React component here using TestUtils and store into Component - }); + beforeEach(function() { + // Setup our tools + React = require('react/addons'); + Navbar = require('../../assets/js/components/Navbar.react.js'); + TestUtils = React.addons.TestUtils; + // Create the React component here using TestUtils and store into Component + }); - it('should work', function() { - expect(2 + 2).toEqual(4); - }); + it('should work', function() { + expect(2 + 2).toEqual(4); + }); }); \ No newline at end of file diff --git a/tests/components/Wakatime.react.jest.js b/tests/components/Wakatime.react.jest.js index 1beedc7..c200c67 100644 --- a/tests/components/Wakatime.react.jest.js +++ b/tests/components/Wakatime.react.jest.js @@ -1,17 +1,17 @@ jest.dontMock('../../assets/js/components/Wakatime.react.js'); describe('Wakatime', function() { - var React, Wakatime, TestUtils, Component; + var React, Wakatime, TestUtils, Component; - beforeEach(function() { - // Setup our tools - React = require('react/addons'); - Wakatime = require('../../assets/js/components/Wakatime.react.js'); - TestUtils = React.addons.TestUtils; - // Create the React component here using TestUtils and store into Component - }); + beforeEach(function() { + // Setup our tools + React = require('react/addons'); + Wakatime = require('../../assets/js/components/Wakatime.react.js'); + TestUtils = React.addons.TestUtils; + // Create the React component here using TestUtils and store into Component + }); - it('should work', function() { - expect(2 + 2).toEqual(4); - }); + it('should work', function() { + expect(2 + 2).toEqual(4); + }); }); \ No newline at end of file diff --git a/tests/helpers/changeExtensionIcon.spec.js b/tests/helpers/changeExtensionIcon.spec.js index fad2a76..98c70be 100644 --- a/tests/helpers/changeExtensionIcon.spec.js +++ b/tests/helpers/changeExtensionIcon.spec.js @@ -4,7 +4,7 @@ var expect = chai.expect; import changeExtensionIcon from '../../assets/js/helpers/changeExtensionIcon'; describe('changeExtensionIcon', function() { - it('should be a function', function() { - expect(changeExtensionIcon).to.be.a('function'); - }); -}); \ No newline at end of file + it('should be a function', function() { + expect(changeExtensionIcon).to.be.a('function'); + }); +}); \ No newline at end of file diff --git a/tests/helpers/currentTimestamp.spec.js b/tests/helpers/currentTimestamp.spec.js index bad6a30..873a5ec 100644 --- a/tests/helpers/currentTimestamp.spec.js +++ b/tests/helpers/currentTimestamp.spec.js @@ -4,7 +4,7 @@ var expect = chai.expect; import currentTimestamp from '../../assets/js/helpers/currentTimestamp'; describe('currentTimestamp', function() { - it('should be a function', function() { - expect(currentTimestamp).to.be.a('function'); - }); -}); \ No newline at end of file + it('should be a function', function() { + expect(currentTimestamp).to.be.a('function'); + }); +}); \ No newline at end of file diff --git a/tests/helpers/getTodaysDateInFormat.spec.js b/tests/helpers/getTodaysDateInFormat.spec.js new file mode 100644 index 0000000..4901c62 --- /dev/null +++ b/tests/helpers/getTodaysDateInFormat.spec.js @@ -0,0 +1,14 @@ +var chai = require('chai'); +var expect = chai.expect; + +import getTodaysDateInFormat from '../../assets/js/helpers/getTodaysDateInFormat'; + +describe('getTodaysDateInFormat', function() { + it('should be a function', function() { + expect(getTodaysDateInFormat).to.be.a('function'); + }); + + it('should return todays date in format YYYY-MM-DD', function() { + expect(getTodaysDateInFormat()).to.be('2015-06-14'); + }); +});