-
Notifications
You must be signed in to change notification settings - Fork 71.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added most basic test for profileeditor
needed to replace new Option() with basic jQuery append since Option wasn't working in the test
- Loading branch information
1 parent
8cb893d
commit 4978830
Showing
2 changed files
with
163 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
'use strict'; | ||
|
||
require('should'); | ||
var benv = require('benv'); | ||
var read = require('fs').readFileSync; | ||
var serverSettings = require('./fixtures/default-server-settings'); | ||
|
||
var nowData = { | ||
sgvs: [ | ||
{ mgdl: 100, mills: Date.now(), direction: 'Flat', type: 'sgv' } | ||
] | ||
}; | ||
|
||
|
||
var defaultprofile = { | ||
//General values | ||
'dia':3, | ||
|
||
// Simple style values, 'from' are in minutes from midnight | ||
'carbratio': [ | ||
{ | ||
'time': '00:00', | ||
'value': 30 | ||
}], | ||
'carbs_hr':30, | ||
'delay': 20, | ||
'sens': [ | ||
{ | ||
'time': '00:00', | ||
'value': 17 | ||
}], | ||
'startDate': new Date(), | ||
'timezone': 'UTC', | ||
|
||
//perGIvalues style values | ||
'perGIvalues': false, | ||
'carbs_hr_high': 30, | ||
'carbs_hr_medium': 30, | ||
'carbs_hr_low': 30, | ||
'delay_high': 15, | ||
'delay_medium': 20, | ||
'delay_low': 20, | ||
|
||
'basal':[ | ||
{ | ||
'time': '00:00', | ||
'value': 0.1 | ||
}], | ||
'target_low':[ | ||
{ | ||
'time': '00:00', | ||
'value': 0 | ||
}], | ||
'target_high':[ | ||
{ | ||
'time': '00:00', | ||
'value': 0 | ||
}] | ||
}; | ||
defaultprofile.startDate.setSeconds(0); | ||
defaultprofile.startDate.setMilliseconds(0); | ||
|
||
|
||
describe('profile editor', function ( ) { | ||
var self = this; | ||
|
||
before(function (done) { | ||
benv.setup(function() { | ||
self.$ = require('jquery'); | ||
self.$.localStorage = require('./fixtures/localstorage'); | ||
|
||
self.$.fn.tipsy = function mockTipsy ( ) { }; | ||
|
||
var indexHtml = read(__dirname + '/../static/profile/index.html', 'utf8'); | ||
self.$('body').html(indexHtml); | ||
|
||
self.$.ajax = function mockAjax (url, opts) { | ||
return { | ||
done: function mockDone (fn) { | ||
if (opts && opts.success && opts.success.call) { | ||
opts.success([defaultprofile]); | ||
} | ||
fn(); | ||
} | ||
}; | ||
}; | ||
|
||
var d3 = require('d3'); | ||
//disable all d3 transitions so most of the other code can run with jsdom | ||
d3.timer = function mockTimer() { }; | ||
|
||
benv.expose({ | ||
$: self.$ | ||
, jQuery: self.$ | ||
, d3: d3 | ||
, serverSettings: serverSettings | ||
, io: { | ||
connect: function mockConnect ( ) { | ||
return { | ||
on: function mockOn ( ) { } | ||
}; | ||
} | ||
} | ||
}); | ||
|
||
benv.require(__dirname + '/../bundle/bundle.source.js'); | ||
benv.require(__dirname + '/../static/profile/js/profile.js'); | ||
|
||
done(); | ||
}); | ||
}); | ||
|
||
after(function (done) { | ||
benv.teardown(true); | ||
done(); | ||
}); | ||
|
||
it ('don\'t blow up', function (done) { | ||
var plugins = require('../lib/plugins/')().registerClientDefaults(); | ||
var client = require('../lib/client'); | ||
|
||
var hashauth = require('../lib/hashauth'); | ||
hashauth.init(client,$); | ||
hashauth.verifyAuthentication = function mockVerifyAuthentication(next) { | ||
hashauth.authenticated = true; | ||
next(true); | ||
}; | ||
|
||
|
||
client.init(serverSettings, plugins); | ||
client.dataUpdate(nowData); | ||
|
||
done(); | ||
}); | ||
|
||
}); |
4978830
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe you should make this page plugin first because you'll need to rewrite tests after change
4978830#diff-701fa5ed63f8c62d599232a36b18f37bR74
this will probably not work after refactoring as we expect to have only fragments there