From 44ed1848548d4c73c35c3302fc47ebfc8295dcae Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Sun, 9 Sep 2012 16:46:12 -0400 Subject: Add more tests, and remove old settings code. --- tests/unit_tests/commands_test.coffee | 10 ++++++++++ tests/unit_tests/settings_test.coffee | 30 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/unit_tests/commands_test.coffee create mode 100644 tests/unit_tests/settings_test.coffee (limited to 'tests') diff --git a/tests/unit_tests/commands_test.coffee b/tests/unit_tests/commands_test.coffee new file mode 100644 index 00000000..99e0e444 --- /dev/null +++ b/tests/unit_tests/commands_test.coffee @@ -0,0 +1,10 @@ +require "./test_helper.js" +{Commands} = require "../../background_scripts/commands.js" + +context "Key mappings", + should "lowercase keys correctly", -> + assert.equal (Commands.normalizeKey ''), '' + assert.equal (Commands.normalizeKey ''), '' + assert.equal (Commands.normalizeKey ''), '' + assert.equal (Commands.normalizeKey ''), '' + assert.equal (Commands.normalizeKey ''), '' diff --git a/tests/unit_tests/settings_test.coffee b/tests/unit_tests/settings_test.coffee new file mode 100644 index 00000000..f86d63dc --- /dev/null +++ b/tests/unit_tests/settings_test.coffee @@ -0,0 +1,30 @@ +require "./test_helper.js" + +{Utils} = require "../../lib/utils.js" +Utils.getCurrentVersion = -> '1.39' +global.localStorage = {} +{Settings} = 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 -- cgit v1.2.3