Skip to content

Commit

Permalink
t2 crash-reporter: more preferences.json tests
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed Apr 22, 2016
1 parent 4054a03 commit 32564aa
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/unit/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,34 @@ exports['Preferences.read'] = {
done();
},

readEmptyFile: function(test) {
test.expect(1);

var defaultValue = 'value';
this.readFile = this.sandbox.stub(fs, 'readFile', (file, handler) => {
handler(null, '');
});

Preferences.read('key', defaultValue).then(result => {
test.equal(result, defaultValue);
test.done();
});
},

readError: function(test) {
test.expect(1);

var defaultValue = 'value';
this.readFile = this.sandbox.stub(fs, 'readFile', (file, handler) => {
handler(new Error('this should not matter'));
});

Preferences.read('key', defaultValue).then(result => {
test.equal(result, defaultValue);
test.done();
});
},

readWithDefaults: function(test) {
test.expect(1);

Expand Down

0 comments on commit 32564aa

Please sign in to comment.