mirror of
https://github.com/koreader/koreader
synced 2024-11-11 19:11:14 +00:00
da2c57f93a
* Add bash scripts to control WIFI / IP, so we can share them with frontend/device/kobo/device.lua. * add test cases
43 lines
1.4 KiB
Lua
43 lines
1.4 KiB
Lua
describe("luasettings module", function()
|
|
local Settings
|
|
setup(function()
|
|
require("commonrequire")
|
|
Settings = require("frontend/luasettings"):open("this-is-not-a-valid-file")
|
|
end)
|
|
|
|
it("should handle undefined keys", function()
|
|
Settings:delSetting("abc")
|
|
|
|
assert.True(Settings:hasNot("abc"))
|
|
assert.True(Settings:nilOrTrue("abc"))
|
|
assert.False(Settings:isTrue("abc"))
|
|
Settings:saveSetting("abc", true)
|
|
assert.True(Settings:has("abc"))
|
|
assert.True(Settings:nilOrTrue("abc"))
|
|
assert.True(Settings:isTrue("abc"))
|
|
end)
|
|
|
|
it("should flip bool values", function()
|
|
Settings:delSetting("abc")
|
|
|
|
assert.True(Settings:hasNot("abc"))
|
|
Settings:flipNilOrTrue("abc")
|
|
assert.False(Settings:nilOrTrue("abc"))
|
|
assert.True(Settings:has("abc"))
|
|
assert.False(Settings:isTrue("abc"))
|
|
Settings:flipNilOrTrue("abc")
|
|
assert.True(Settings:nilOrTrue("abc"))
|
|
assert.True(Settings:hasNot("abc"))
|
|
assert.False(Settings:isTrue("abc"))
|
|
|
|
Settings:flipTrue("abc")
|
|
assert.True(Settings:has("abc"))
|
|
assert.True(Settings:isTrue("abc"))
|
|
assert.True(Settings:nilOrTrue("abc"))
|
|
Settings:flipTrue("abc")
|
|
assert.False(Settings:has("abc"))
|
|
assert.False(Settings:isTrue("abc"))
|
|
assert.True(Settings:nilOrTrue("abc"))
|
|
end)
|
|
end)
|