Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

renew options-page

  • Loading branch information...
commit 7981d3efccf18535ad8695f1ce0576b7f89eb42b 1 parent fe0ab70
@ninoseki authored
View
1  README.md
@@ -12,6 +12,7 @@ Contributors
============
* [jcplessis](https://github.com/jcplessis)
+* [klamping](https://github.com/klamping)
*Thank you!*
View
3  app/application.coffee
@@ -15,6 +15,7 @@ Application =
WorkingView = require 'views/working_view'
RestingView = require 'views/resting_view'
StatsView = require 'views/stats_view'
+
MainRouter = require 'routers/main_router'
@router = new MainRouter()
@@ -39,7 +40,7 @@ Application =
@settings = {}
@settings.date_format = "YYYY-MM-DD"
- @development = true
+ @development = false
# Freeze the object
Object.freeze? Application
View
8 app/assets/javascripts/options.js
@@ -31,9 +31,9 @@ function restore_options() {
}
$(function() {
- restore_options();
+ OptionsView = require('/views/options_view');
+ optionsView = new OptionsView();
+ console.debug(optionsView);
+ optionsView.render();
- $('#submit').click(function() {
- save_options();
- });
});
View
55 app/assets/options.html
@@ -1,27 +1,38 @@
<html>
-<head><title>Pomodoro Daisuki</title></head>
-<script type="text/javascript" src="javascripts/vendor.js"></script>
-<script type="text/javascript" src="javascripts/options.js"></script>
+<head>
+ <meta charset="utf-8">
+ <title>Pomodoro Daisuki</title>
+
+ <link rel="shortcut icon" href="images/tomato_16.png" type="image/png"/>
+ <link rel="stylesheet" href="stylesheets/app.css">
+ <link rel="stylesheet" href="stylesheets/options.css">
+ <script type="text/javascript" src="javascripts/vendor.js"></script>
+ <script type="text/javascript" src="javascripts/app.js"></script>
+ <script type="text/javascript" src="javascripts/options.js"></script>
+</head>
<body>
-<table>
- <tr>
- <td>Duration of a pomodoro</td>
- <td><input id="pomodoro-duration" size=2 value="25"/></td>
- <td>minutes</td>
- </tr>
- <tr>
- <td>Duration of a short break</td>
- <td><input id="short-duration" size=2 value="5"/></td>
- <td>minutes</td>
- </tr>
- <tr>
- <td>Duration of a long break</td>
- <td><input id="long-duration" size=2 value="15"/></td>
- <td>minutes</td>
- </tr>
-</table>
-<button id="submit">Save</button>
-<span id="status"></span>
+<!-- navbar -->
+<div class="navbar navbar-inverse navbar-fixed-top">
+ <div class="navbar-inner">
+ <div class="container">
+ <img class="brand-image" src="images/tomato_32.png" alt="tomato">
+ <a class="brand" href="#">Pomodoro Daisuki</a>
+ </div>
+ </div>
+</div>
+<!-- /navbar -->
+
+<!-- main -->
+<div id ="main">
+ <div class="container">
+ <div id="modal" class="modal">
+
+ </div>
+ </div>
+</div>
+<!-- /main -->
+
+
</body>
</html>
View
15 app/assets/stylesheets/options.css
@@ -0,0 +1,15 @@
+.form-horizontal .control-label {
+ float: left;
+ width: 240px;
+ padding-top: 5px;
+ text-align: right;
+}
+
+.form-horizontal .controls {
+ margin-left: 20px;
+}
+
+.form-horizontal .controls input {
+ height: auto;
+}
+
View
12 app/models/timer_config.coffee
@@ -0,0 +1,12 @@
+Model = require './model'
+
+module.exports = class TimerConfig extends Model
+ initialize: ->
+ @set 'pomodoroDuration', localStorage.getItem('pomodoroDuration') ? 25
+ @set 'shortBreakDuration', localStorage.getItem('shortBreakDuration') ? 5
+ @set 'longBreakDuration', localStorage.getItem('longBreakDuration') ? 15
+
+ update: (data) ->
+ for key, value of data
+ localStorage.setItem(key, value)
+ @set key, value
View
27 app/routers/main_router.coffee
@@ -1,4 +1,5 @@
application = require 'application'
+TimerConfig = require '../models/timer_config'
module.exports = class MainRouter extends Backbone.Router
routes :
@@ -6,30 +7,29 @@ module.exports = class MainRouter extends Backbone.Router
"working" : "working"
"resting/:rest_type" : "resting"
"stats" : "stats"
- "small-timer" : "small_timer"
+ "small-timer" : "smallTimer"
- home: ->
+ initialize: ->
+ @timerConfig = new TimerConfig()
+
+ home: (type) ->
application.homeView.render()
application.notes.fetch()
application.columns.fetch()
- application.states.setCurrentStateName('home')
-
+ if type != 'onWorking'
+ application.states.setCurrentStateName('home')
working: ->
application.workingView.render()
- duration = localStorage["pomodoro-duration"]
- if ! duration then duration = 25
+ duration = @timerConfig.get 'pomodoroDuration'
application.workingView.startTimer(if application.development == true then 10 else duration * 60)
application.states.setCurrentStateName('working')
- resting: (rest_type) ->
+ resting: (restType) ->
application.restingView.render()
- duration = localStorage[rest_type + "-duration"]
- if ! duration
- if rest_type == "short" then duration = 5
- if rest_type == "long" then duration = 15
+ duration = @timerConfig.get restType + 'BreakDuration'
application.restingView.startTimer(if application.development == true then 10 else duration * 60)
application.states.setCurrentStateName('resting/' + rest_type)
@@ -38,6 +38,7 @@ module.exports = class MainRouter extends Backbone.Router
application.pomodoros.fetch()
application.statsView.render()
- small_timer: ->
+ smallTimer: ->
$("#modal").modal("show")
- application.router.navigate 'home', true
+
+ application.router.navigate 'home/onWorking', true
View
24 app/views/options_view.coffee
@@ -0,0 +1,24 @@
+View = require './view'
+TimerConfig = require '../models/timer_config'
+template = require './templates/options'
+
+module.exports = class OptionsView extends View
+ template: template
+ el: "#modal"
+
+ events:
+ "click #update": "update"
+
+ initialize: ->
+ @timerConfig = new TimerConfig()
+
+ getRenderData: ->
+ @timerConfig.toJSON()
+
+ update: ->
+ data =
+ pomodoroDuration : $('#inputPomodoroDuration').val()
+ shortBreakDuration : $('#inputShortBreakDuration').val()
+ longBreakDuration : $('#inputLongBreakDuration').val()
+
+ @timerConfig.update data
View
28 app/views/templates/options.eco
@@ -0,0 +1,28 @@
+<div class="modal-header">
+ <h3>Options</h3>
+</div>
+<div class="modal-body">
+ <form class="form-horizontal">
+ <div class="control-group">
+ <label class="control-label" for="inputPomodoroDuration">Duration of a pomodoro</label>
+ <div class="controls input-append">
+ <input class="input-small" type="number" id="inputPomodoroDuration" value="<%= @pomodoroDuration %>"><span class="add-on">minutes</span>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="inputDurationShortBreak">Duration of a short break</label>
+ <div class="controls input-append">
+ <input class="input-small" type="number" id="inputShortBreakDuration" value="<%= @shortBreakDuration %>"><span class="add-on">minutes</span>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="inputDurationLongBreak">Duration of a long break</label>
+ <div class="controls input-append">
+ <input class="input-small" type="number" id="inputLongBreakDuration" value="<%= @longBreakDuration %>"><span class="add-on">minutes</span>
+ </div>
+ </div>
+ </form>
+</div>
+<div class="modal-footer">
+ <a href="#" id="update" class="btn btn-primary">Save changes</a>
+</div>
View
2  manifest.json
@@ -1,6 +1,6 @@
{
"name": "Pomodoro Daisuki",
- "version": "0.48",
+ "version": "0.50",
"manifest_version": 2,
"description": "Tool for Pomodoro Technique",
"icons": {
View
192 public/javascripts/app.js
@@ -110,7 +110,7 @@ window.require.define({"application": function(exports, require, module) {
this.audios.alarm = new Audio("audios/alarm.wav");
this.settings = {};
this.settings.date_format = "YYYY-MM-DD";
- this.development = true;
+ this.development = false;
return typeof Object.freeze === "function" ? Object.freeze(Application) : void 0;
}
};
@@ -436,13 +436,54 @@ window.require.define({"models/state": function(exports, require, module) {
}});
+window.require.define({"models/timer_config": function(exports, require, module) {
+ var Model, TimerConfig,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Model = require('./model');
+
+ module.exports = TimerConfig = (function(_super) {
+
+ __extends(TimerConfig, _super);
+
+ function TimerConfig() {
+ return TimerConfig.__super__.constructor.apply(this, arguments);
+ }
+
+ TimerConfig.prototype.initialize = function() {
+ var _ref, _ref1, _ref2;
+ this.set('pomodoroDuration', (_ref = localStorage.getItem('pomodoroDuration')) != null ? _ref : 25);
+ this.set('shortBreakDuration', (_ref1 = localStorage.getItem('shortBreakDuration')) != null ? _ref1 : 5);
+ return this.set('longBreakDuration', (_ref2 = localStorage.getItem('longBreakDuration')) != null ? _ref2 : 15);
+ };
+
+ TimerConfig.prototype.update = function(data) {
+ var key, value, _results;
+ _results = [];
+ for (key in data) {
+ value = data[key];
+ localStorage.setItem(key, value);
+ _results.push(this.set(key, value));
+ }
+ return _results;
+ };
+
+ return TimerConfig;
+
+ })(Model);
+
+}});
+
window.require.define({"routers/main_router": function(exports, require, module) {
- var MainRouter, application,
+ var MainRouter, TimerConfig, application,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
application = require('application');
+ TimerConfig = require('../models/timer_config');
+
module.exports = MainRouter = (function(_super) {
__extends(MainRouter, _super);
@@ -456,39 +497,34 @@ window.require.define({"routers/main_router": function(exports, require, module)
"working": "working",
"resting/:rest_type": "resting",
"stats": "stats",
- "small-timer": "small_timer"
+ "small-timer": "smallTimer"
+ };
+
+ MainRouter.prototype.initialize = function() {
+ return this.timerConfig = new TimerConfig();
};
- MainRouter.prototype.home = function() {
+ MainRouter.prototype.home = function(type) {
application.homeView.render();
application.notes.fetch();
application.columns.fetch();
- return application.states.setCurrentStateName('home');
+ if (type !== 'onWorking') {
+ return application.states.setCurrentStateName('home');
+ }
};
MainRouter.prototype.working = function() {
var duration;
application.workingView.render();
- duration = localStorage["pomodoro-duration"];
- if (!duration) {
- duration = 25;
- }
+ duration = this.timerConfig.get('pomodoroDuration');
application.workingView.startTimer(application.development === true ? 10 : duration * 60);
return application.states.setCurrentStateName('working');
};
- MainRouter.prototype.resting = function(rest_type) {
+ MainRouter.prototype.resting = function(restType) {
var duration;
application.restingView.render();
- duration = localStorage[rest_type + "-duration"];
- if (!duration) {
- if (rest_type === "short") {
- duration = 5;
- }
- if (rest_type === "long") {
- duration = 15;
- }
- }
+ duration = this.timerConfig.get(restType + 'BreakDuration');
application.restingView.startTimer(application.development === true ? 10 : duration * 60);
return application.states.setCurrentStateName('resting/' + rest_type);
};
@@ -498,9 +534,9 @@ window.require.define({"routers/main_router": function(exports, require, module)
return application.statsView.render();
};
- MainRouter.prototype.small_timer = function() {
+ MainRouter.prototype.smallTimer = function() {
$("#modal").modal("show");
- return application.router.navigate('home', true);
+ return application.router.navigate('home/onWorking', true);
};
return MainRouter;
@@ -959,6 +995,57 @@ window.require.define({"views/notes_view": function(exports, require, module) {
}});
+window.require.define({"views/options_view": function(exports, require, module) {
+ var OptionsView, TimerConfig, View, template,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ View = require('./view');
+
+ TimerConfig = require('../models/timer_config');
+
+ template = require('./templates/options');
+
+ module.exports = OptionsView = (function(_super) {
+
+ __extends(OptionsView, _super);
+
+ function OptionsView() {
+ return OptionsView.__super__.constructor.apply(this, arguments);
+ }
+
+ OptionsView.prototype.template = template;
+
+ OptionsView.prototype.el = "#modal";
+
+ OptionsView.prototype.events = {
+ "click #update": "update"
+ };
+
+ OptionsView.prototype.initialize = function() {
+ return this.timerConfig = new TimerConfig();
+ };
+
+ OptionsView.prototype.getRenderData = function() {
+ return this.timerConfig.toJSON();
+ };
+
+ OptionsView.prototype.update = function() {
+ var data;
+ data = {
+ pomodoroDuration: $('#inputPomodoroDuration').val(),
+ shortBreakDuration: $('#inputShortBreakDuration').val(),
+ longBreakDuration: $('#inputLongBreakDuration').val()
+ };
+ return this.timerConfig.update(data);
+ };
+
+ return OptionsView;
+
+ })(View);
+
+}});
+
window.require.define({"views/resting_view": function(exports, require, module) {
var RestingView, View, application, template,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
@@ -1531,6 +1618,69 @@ window.require.define({"views/templates/notes": function(exports, require, modul
}
}});
+window.require.define({"views/templates/options": function(exports, require, module) {
+ module.exports = function (__obj) {
+ if (!__obj) __obj = {};
+ var __out = [], __capture = function(callback) {
+ var out = __out, result;
+ __out = [];
+ callback.call(this);
+ result = __out.join('');
+ __out = out;
+ return __safe(result);
+ }, __sanitize = function(value) {
+ if (value && value.ecoSafe) {
+ return value;
+ } else if (typeof value !== 'undefined' && value != null) {
+ return __escape(value);
+ } else {
+ return '';
+ }
+ }, __safe, __objSafe = __obj.safe, __escape = __obj.escape;
+ __safe = __obj.safe = function(value) {
+ if (value && value.ecoSafe) {
+ return value;
+ } else {
+ if (!(typeof value !== 'undefined' && value != null)) value = '';
+ var result = new String(value);
+ result.ecoSafe = true;
+ return result;
+ }
+ };
+ if (!__escape) {
+ __escape = __obj.escape = function(value) {
+ return ('' + value)
+ .replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;');
+ };
+ }
+ (function() {
+ (function() {
+
+ __out.push('<div class="modal-header">\n <h3>Options</h3>\n</div>\n<div class="modal-body">\n <form class="form-horizontal">\n <div class="control-group">\n <label class="control-label" for="inputPomodoroDuration">Duration of a pomodoro</label>\n <div class="controls input-append">\n <input class="input-small" type="number" id="inputPomodoroDuration" value="');
+
+ __out.push(__sanitize(this.pomodoroDuration));
+
+ __out.push('"><span class="add-on">minutes</span>\n </div>\n </div>\n <div class="control-group">\n <label class="control-label" for="inputDurationShortBreak">Duration of a short break</label>\n <div class="controls input-append">\n <input class="input-small" type="number" id="inputShortBreakDuration" value="');
+
+ __out.push(__sanitize(this.shortBreakDuration));
+
+ __out.push('"><span class="add-on">minutes</span>\n </div>\n </div>\n <div class="control-group">\n <label class="control-label" for="inputDurationLongBreak">Duration of a long break</label>\n <div class="controls input-append">\n <input class="input-small" type="number" id="inputLongBreakDuration" value="');
+
+ __out.push(__sanitize(this.longBreakDuration));
+
+ __out.push('"><span class="add-on">minutes</span>\n </div>\n </div>\n </form>\n</div>\n<div class="modal-footer">\n <a href="#" id="update" class="btn btn-primary">Save changes</a>\n</div>');
+
+ }).call(this);
+
+ }).call(__obj);
+ __obj.safe = __objSafe, __obj.escape = __escape;
+ return __out.join('');
+ }
+}});
+
window.require.define({"views/templates/stats": function(exports, require, module) {
module.exports = function (__obj) {
if (!__obj) __obj = {};
View
8 public/javascripts/options.js
@@ -31,9 +31,9 @@ function restore_options() {
}
$(function() {
- restore_options();
+ OptionsView = require('/views/options_view');
+ optionsView = new OptionsView();
+ console.debug(optionsView);
+ optionsView.render();
- $('#submit').click(function() {
- save_options();
- });
});
View
136 public/javascripts/vendor.js
@@ -14884,73 +14884,73 @@ getOptions:function(){return M},hasBidiBug:Pb,numberFormat:Ia,seriesTypes:$,setO
})(Date);;
-(function ($) {
- function configuration(settings) {
- return $.extend({
- seconds:60,
- tick:function (timer, formatted_time) {
- },
- format:'mm:ss',
- reset:false,
- show_in_title:false,
- origin_title:undefined,
- buzzer:function () {
- }
- }, settings);
- }
-
- $.fn.extend({
- startTimer:function (settings) {
- var timer = $(this);
- var settings = configuration(settings);
- var origin_title = document.title;
-
- return this.each(function () {
- if (localStorage['jquery.countdown.ended_at'] === undefined || settings.reset) {
- localStorage['jquery.countdown.ended_at'] = new Date().getTime() + settings.seconds * 1000;
- }
- var tick = function () {
- var ended_at = localStorage['jquery.countdown.ended_at'];
- var current_time = parseInt(ended_at) - new Date().getTime();
-
- if (current_time < 0 || isNaN(current_time)) {
- timer.clearTimer();
-
- // when not called clearTimer externally
- if (ended_at !== undefined) {
- settings.buzzer();
- }
- if (settings.show_in_title) {
- document.title = origin_title;
- }
-
- return false;
- } else {
- // var formatted_time = new Date(current_time).toString(settings.format);
- var formatted_time = moment(current_time).format(settings.format);
- timer.text(formatted_time);
- if (settings.show_in_title) {
- document.title = formatted_time;
- }
-
- return true;
- }
- };
-
- if (tick()) {
- var interval = setInterval(function () {
- if (!tick()) {
- clearInterval(interval);
- }
- }, 1000);
- }
- });
- },
- clearTimer:function () {
- localStorage.removeItem('jquery.countdown.ended_at');
- }
- });
-})(jQuery);
-
+(function ($) {
+ function configuration(settings) {
+ return $.extend({
+ seconds:60,
+ tick:function (timer, formatted_time) {
+ },
+ format:'mm:ss',
+ reset:false,
+ show_in_title:false,
+ origin_title:undefined,
+ buzzer:function () {
+ }
+ }, settings);
+ }
+
+ $.fn.extend({
+ startTimer:function (settings) {
+ var timer = $(this);
+ var settings = configuration(settings);
+ var origin_title = document.title;
+
+ return this.each(function () {
+ if (localStorage['jquery.countdown.ended_at'] === undefined || settings.reset) {
+ localStorage['jquery.countdown.ended_at'] = new Date().getTime() + settings.seconds * 1000;
+ }
+ var tick = function () {
+ var ended_at = localStorage['jquery.countdown.ended_at'];
+ var current_time = parseInt(ended_at) - new Date().getTime();
+
+ if (current_time < 0 || isNaN(current_time)) {
+ timer.clearTimer();
+
+ // when not called clearTimer externally
+ if (ended_at !== undefined) {
+ settings.buzzer();
+ }
+ if (settings.show_in_title) {
+ document.title = origin_title;
+ }
+
+ return false;
+ } else {
+ // var formatted_time = new Date(current_time).toString(settings.format);
+ var formatted_time = moment(current_time).format(settings.format);
+ timer.text(formatted_time);
+ if (settings.show_in_title) {
+ document.title = formatted_time;
+ }
+
+ return true;
+ }
+ };
+
+ if (tick()) {
+ var interval = setInterval(function () {
+ if (!tick()) {
+ clearInterval(interval);
+ }
+ }, 1000);
+ }
+ });
+ },
+ clearTimer:function () {
+ localStorage.removeItem('jquery.countdown.ended_at');
+ }
+ });
+})(jQuery);
+
;
View
55 public/options.html
@@ -1,27 +1,38 @@
<html>
-<head><title>Pomodoro Daisuki</title></head>
-<script type="text/javascript" src="javascripts/vendor.js"></script>
-<script type="text/javascript" src="javascripts/options.js"></script>
+<head>
+ <meta charset="utf-8">
+ <title>Pomodoro Daisuki</title>
+
+ <link rel="shortcut icon" href="images/tomato_16.png" type="image/png"/>
+ <link rel="stylesheet" href="stylesheets/app.css">
+ <link rel="stylesheet" href="stylesheets/options.css">
+ <script type="text/javascript" src="javascripts/vendor.js"></script>
+ <script type="text/javascript" src="javascripts/app.js"></script>
+ <script type="text/javascript" src="javascripts/options.js"></script>
+</head>
<body>
-<table>
- <tr>
- <td>Duration of a pomodoro</td>
- <td><input id="pomodoro-duration" size=2 value="25"/></td>
- <td>minutes</td>
- </tr>
- <tr>
- <td>Duration of a short break</td>
- <td><input id="short-duration" size=2 value="5"/></td>
- <td>minutes</td>
- </tr>
- <tr>
- <td>Duration of a long break</td>
- <td><input id="long-duration" size=2 value="15"/></td>
- <td>minutes</td>
- </tr>
-</table>
-<button id="submit">Save</button>
-<span id="status"></span>
+<!-- navbar -->
+<div class="navbar navbar-inverse navbar-fixed-top">
+ <div class="navbar-inner">
+ <div class="container">
+ <img class="brand-image" src="images/tomato_32.png" alt="tomato">
+ <a class="brand" href="#">Pomodoro Daisuki</a>
+ </div>
+ </div>
+</div>
+<!-- /navbar -->
+
+<!-- main -->
+<div id ="main">
+ <div class="container">
+ <div id="modal" class="modal">
+
+ </div>
+ </div>
+</div>
+<!-- /main -->
+
+
</body>
</html>
View
15 public/stylesheets/options.css
@@ -0,0 +1,15 @@
+.form-horizontal .control-label {
+ float: left;
+ width: 240px;
+ padding-top: 5px;
+ text-align: right;
+}
+
+.form-horizontal .controls {
+ margin-left: 20px;
+}
+
+.form-horizontal .controls input {
+ height: auto;
+}
+
View
32 public/test/javascripts/test.js
@@ -172,6 +172,37 @@ window.require.define({"test/models/note_test": function(exports, require, modul
}});
+window.require.define({"test/models/timer_config_test": function(exports, require, module) {
+ var TimerConfig;
+
+ TimerConfig = require('models/timer_config');
+
+ describe('TimerConfig Model', function() {
+ beforeEach(function() {
+ localStorage.clear();
+ return this.timerConfig = new TimerConfig();
+ });
+ it('should set defaults', function() {
+ (expect(this.timerConfig.get('pomodoroDuration'))).to.equal(25);
+ (expect(this.timerConfig.get('shortBreakDuration'))).to.equal(5);
+ return (expect(this.timerConfig.get('longBreakDuration'))).to.equal(15);
+ });
+ return it('should update', function() {
+ var data;
+ data = {
+ pomodoroDuration: 100,
+ shortBreakDuration: 110,
+ longBreakDuration: 120
+ };
+ this.timerConfig.update(data);
+ (expect(this.timerConfig.get('pomodoroDuration'))).to.equal(100);
+ (expect(this.timerConfig.get('shortBreakDuration'))).to.equal(110);
+ return (expect(this.timerConfig.get('longBreakDuration'))).to.equal(120);
+ });
+ });
+
+}});
+
window.require.define({"test/spec": function(exports, require, module) {
@@ -297,6 +328,7 @@ window.require.define({"test/views/working_view_test": function(exports, require
window.require('test/collections/stats_test');
window.require('test/models/column_test');
window.require('test/models/note_test');
+window.require('test/models/timer_config_test');
window.require('test/views/column_view_test');
window.require('test/views/columns_view_test');
window.require('test/views/home_view_test');
View
29 test/models/timer_config_test.coffee
@@ -0,0 +1,29 @@
+TimerConfig = require 'models/timer_config'
+
+describe 'TimerConfig Model', ->
+
+ beforeEach ->
+ localStorage.clear()
+ @timerConfig = new TimerConfig()
+
+ it 'should set defaults', ->
+ (expect @timerConfig.get('pomodoroDuration')).to.equal 25
+ (expect @timerConfig.get('shortBreakDuration')).to.equal 5
+ (expect @timerConfig.get('longBreakDuration')).to.equal 15
+
+ it 'should update', ->
+ data =
+ pomodoroDuration : 100
+ shortBreakDuration : 110
+ longBreakDuration : 120
+
+ @timerConfig.update data
+
+ (expect @timerConfig.get('pomodoroDuration')).to.equal 100
+ (expect @timerConfig.get('shortBreakDuration')).to.equal 110
+ (expect @timerConfig.get('longBreakDuration')).to.equal 120
+
+
+
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.