Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/browserbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@
if (!item || !item.attributes || item.attributes.length < 3) {
return;
}
var branch = this._ensurePath(tree, (item.attributes[2].value || '').toString(), (item.attributes[1].value).toString());
var branch = this._ensurePath(tree, (item.attributes[2].value || '').toString(), (item.attributes[1] ? item.attributes[1].value : '/').toString());
branch.flags = [].concat(item.attributes[0] || []).map(function(flag) {
return (flag.value || '').toString();
});
Expand Down
44 changes: 41 additions & 3 deletions test/unit/browserbox-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

(function(factory) {
if (typeof define === 'function' && define.amd) {
define(['chai', 'sinon', 'axe', 'browserbox', './fixtures/mime-torture-bodystructure', './fixtures/envelope'], factory);
define(['chai', 'sinon', 'axe', 'browserbox', 'imap-handler', './fixtures/mime-torture-bodystructure', './fixtures/envelope'], factory);
} else if (typeof exports === 'object') {
module.exports = factory(require('chai'), require('sinon'), require('axe-logger'), require('browserbox'), require('./fixtures/mime-torture-bodystructure'), require('./fixtures/envelope'));
module.exports = factory(require('chai'), require('sinon'), require('axe-logger'), require('browserbox'), require('imap-handler'), require('./fixtures/mime-torture-bodystructure'), require('./fixtures/envelope'));
}
}(function(chai, sinon, axe, BrowserBox, mimeTorture, testEnvelope) {
}(function(chai, sinon, axe, BrowserBox, imapHandler, mimeTorture, testEnvelope) {
var expect = chai.expect;
chai.Assertion.includeStack = true;

Expand Down Expand Up @@ -505,6 +505,44 @@
expect(tree).to.exist;
});
});

it('should not die on NIL separators', function(done) {
sinon.stub(br, 'exec', function(command, untagged, callback) {
br.exec.restore();
sinon.stub(br, 'exec', function(command, untagged, callback) {
br.exec.restore();

expect(command).to.deep.equal({
command: 'LSUB',
attributes: ['', '*']
});
callback(null, {
payload: {
LSUB: [false]
}
}, function() {
done();
});
});

expect(command).to.deep.equal({
command: 'LIST',
attributes: ['', '*']
});
callback(null, {
payload: {
LIST: [
imapHandler.parser('* LIST (\\NoInferiors) NIL "INBOX"')
]
}
}, function() {});
});

br.listMailboxes(function(err, tree) {
expect(err).to.not.exist;
expect(tree).to.exist;
});
});
});

describe('#listMessages', function() {
Expand Down