Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
75
gaia/apps/clock/test/unit/onring_test.js
Executable file
75
gaia/apps/clock/test/unit/onring_test.js
Executable file
|
|
@ -0,0 +1,75 @@
|
|||
/* global require, document, require, loadBodyHTML */
|
||||
/* global MockIntlHelper, MockMozIntl */
|
||||
|
||||
suite('Ring Test', function() {
|
||||
'use strict';
|
||||
|
||||
var RingView;
|
||||
suiteSetup(function(done) {
|
||||
window.IntlHelper = MockIntlHelper;
|
||||
window.mozIntl = MockMozIntl;
|
||||
require(['ring_view'],
|
||||
function(_RingView) {
|
||||
RingView = _RingView;
|
||||
loadBodyHTML('/onring.html');
|
||||
// Force document.hidden to be 'false' so that the alarm
|
||||
// properly triggers visible callbacks in ring_view.js
|
||||
Object.defineProperty(document, 'hidden', {value: false});
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
[
|
||||
{ vibrate: true, shouldVibrate: true },
|
||||
{ vibrate: '1', shouldVibrate: true },
|
||||
{ vibrate: false, shouldVibrate: false }
|
||||
].forEach(function(testCase) {
|
||||
var { vibrate, shouldVibrate } = testCase;
|
||||
|
||||
test('should ' + (shouldVibrate ? '' : 'not ') +
|
||||
'vibrate when vibrate is set to ' + vibrate, function() {
|
||||
var clock = this.sinon.useFakeTimers();
|
||||
var mock = this.sinon.mock(navigator);
|
||||
if (shouldVibrate) {
|
||||
mock.expects('vibrate').atLeast(1);
|
||||
} else {
|
||||
mock.expects('vibrate').never();
|
||||
}
|
||||
var view = new RingView();
|
||||
view.addAlert({
|
||||
type: 'alarm',
|
||||
vibrate: vibrate,
|
||||
label: 'hi',
|
||||
sound: null,
|
||||
hour: 1,
|
||||
minute: 1,
|
||||
time: new Date(),
|
||||
});
|
||||
clock.tick(5000); // vibrate starts after a setInterval
|
||||
mock.verify();
|
||||
mock.restore();
|
||||
});
|
||||
});
|
||||
|
||||
test('should silence itself after a timeout', function() {
|
||||
var clock = this.sinon.useFakeTimers();
|
||||
var view = new RingView();
|
||||
view.addAlert({
|
||||
type: 'alarm',
|
||||
vibrate: true,
|
||||
label: 'hi',
|
||||
sound: null,
|
||||
hour: 1,
|
||||
minute: 1,
|
||||
time: new Date(),
|
||||
});
|
||||
|
||||
var silenceSpy = this.sinon.spy(view, 'silence');
|
||||
clock.tick(1000); // Wait one second... the alarm should still be ringing
|
||||
assert.isFalse(silenceSpy.called);
|
||||
clock.tick(10 * 60 * 1000); // After 10 minutes, it should be quiet.
|
||||
assert.isTrue(silenceSpy.called);
|
||||
});
|
||||
|
||||
});
|
||||
Loading…
Reference in a new issue