aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit_tests/settings_test.coffee
blob: 040de285f6b894d979d74e00ef0164c8fae21471 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require "./test_helper.js"
require "./test_chrome_stubs.js"

extend(global, require "../../lib/utils.js")
Utils.getCurrentVersion = -> '1.44'
global.localStorage = {}

extend(global,require "../../background_scripts/sync.js")
extend(global,require "../../background_scripts/settings.js")

context "settings",

  setup ->
    stub global, 'localStorage', {}

should "obtain defaults if no key is stored", ->
  assert.isFalse Settings.has 'scrollStepSize'
  assert.equal Settings.get('scrollStepSize'), 60

  should "store values", ->
    Settings.set 'scrollStepSize', 20
    assert.equal Settings.get('scrollStepSize'), 20

should "not store values equal to the default", ->
  Settings.set 'scrollStepSize', 20
  assert.isTrue Settings.has 'scrollStepSize'
  Settings.set 'scrollStepSize', 60
  assert.isFalse Settings.has 'scrollStepSize'

should "revert to defaults if no key is stored", ->
  Settings.set 'scrollStepSize', 20
  Settings.clear 'scrollStepSize'
  assert.equal Settings.get('scrollStepSize'), 60