Empty editors trigger config to delete the associated config key

This commit is contained in:
probablycorey
2013-04-26 10:07:27 -07:00
committed by Corey Johnson & Kevin Sawicki
parent b878be27a0
commit 9f85ba4f7d
2 changed files with 5 additions and 2 deletions

View File

@@ -73,8 +73,10 @@ describe "ConfigPanel", ->
expect(config.get('foo.float')).toBe 3.3
expect(config.get('foo.string')).toBe 'All limitations are self imposed.'
panel.intEditor.setText('')
panel.floatEditor.setText('ha ha')
panel.intEditor.setText('not an int')
panel.floatEditor.setText('not a float')
panel.stringEditor.setText('')
window.advanceClock(10000) # wait for contents-modified to be triggered
expect(config.get('foo.int')).toBe 0
expect(config.get('foo.float')).toBe 0
expect(config.get('foo.string')).toBe undefined

View File

@@ -43,4 +43,5 @@ class ConfigPanel extends View
value = editor.getText()
if type == 'int' then value = parseInt(value) or 0
if type == 'float' then value = parseFloat(value) or 0
if value == "" then value = undefined
config.set name, value