Skip to content

Commit

Permalink
updated notification mock
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdugne committed May 5, 2020
1 parent ef9fa6d commit b45f91d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cherry/extensions/device-notifications.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local notifications = require('plugin.notifications.v2')
local notifications = _G.notifications or require('plugin.notifications.v2')

-- doc https://docs.coronalabs.com/plugin/notifications-v2/scheduleNotification.html

Expand Down
2 changes: 2 additions & 0 deletions test/_startup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ expose(
_G.composer = require('mocks.composer')
_G.http = require('mocks.http')
_G.file = require('mocks.file')
_G.native = require('mocks.native')
_G.network = require('mocks.network')
_G.notifications = require('mocks.notifications')
_G.physics = require('mocks.physics')
_G.Runtime = require('mocks.runtime')
_G.system = require('mocks.system')
Expand Down
6 changes: 6 additions & 0 deletions test/mocks/native.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
local native = {
requestExit = function()
end
}

return native
10 changes: 10 additions & 0 deletions test/mocks/notifications.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
local notifications = {
cancelNotification = function(text, secondsFromNow, id)
return true
end,
scheduleNotification = function(secondsFromNow, options)
return 'scheduled.' .. options.alert
end
}

return notifications
14 changes: 4 additions & 10 deletions test/mocks/system.lua
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
local system = {
pathForFile = function (name, folder)
pathForFile = function(name, folder)
return './' .. name
end,
scheduleNotification = function (secondsFromNow, options)
return 'scheduled.'.. options.alert
end,
cancelNotification = function (id)
return true
end,
getTimer = function()
return '1234'
end
}

system.switchPlatform = function(platform)
system.getInfo = function (info)
if(info == 'platformName') then
system.getInfo = function(info)
if (info == 'platformName') then
return platform
elseif(info == 'environment') then
elseif (info == 'environment') then
return 'simulator'
end
end
Expand Down

0 comments on commit b45f91d

Please sign in to comment.