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
60
gaia/apps/network-alerts/test/unit/notification/notification_test.js
Executable file
60
gaia/apps/network-alerts/test/unit/notification/notification_test.js
Executable file
|
|
@ -0,0 +1,60 @@
|
|||
/* global NotificationHandler
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
require('/js/notification/notification.js');
|
||||
|
||||
suite('Network Alerts - Notification handling', function() {
|
||||
|
||||
setup(function() {
|
||||
this.sinon.stub(window, 'close');
|
||||
this.sinon.stub(window, 'open');
|
||||
// We only need titleID after parsing, so mock parseParams that simply
|
||||
// return fake titleID for testing.
|
||||
|
||||
if (!window.navigator.mozSetMessageHandler) {
|
||||
window.navigator.mozSetMessageHandler = function() {};
|
||||
}
|
||||
this.sinon.stub(window.navigator, 'mozSetMessageHandler');
|
||||
NotificationHandler.init();
|
||||
});
|
||||
|
||||
test('opens an attention screen if user clicks the notification', function() {
|
||||
var message = {
|
||||
title: 'Some title',
|
||||
body: 'Some body',
|
||||
clicked: true,
|
||||
data: { title: 'Some title' }
|
||||
};
|
||||
|
||||
var handlerStub = window.navigator.mozSetMessageHandler;
|
||||
handlerStub.withArgs('notification').yield(message);
|
||||
|
||||
var expectedUrl = [
|
||||
'attention.html?',
|
||||
'title=Some%20title&',
|
||||
'body=Some%20body&',
|
||||
'notification=1'
|
||||
].join('');
|
||||
|
||||
sinon.assert.calledWith(
|
||||
window.open,
|
||||
expectedUrl, '_blank', 'attention'
|
||||
);
|
||||
sinon.assert.notCalled(window.close);
|
||||
});
|
||||
|
||||
test('only closes window if user dismisses the notification', function() {
|
||||
var message = {
|
||||
title: 'Some title',
|
||||
body: 'Some body'
|
||||
};
|
||||
|
||||
var handlerStub = window.navigator.mozSetMessageHandler;
|
||||
handlerStub.withArgs('notification').yield(message);
|
||||
|
||||
sinon.assert.notCalled(window.open);
|
||||
sinon.assert.called(window.close);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in a new issue