File tree Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,17 @@ client.createMailbox('INBOX/Foo').then(() => { ... });
232232// Do the same on a server where the personal namespace is ''
233233client .createMailbox (' Foo' ).then (() => { ... });
234234```
235+ ## Delete mailbox
236+
237+ Delete a folder with the given path with ` deleteMailbox(path) ` , automatically handling utf-7 encoding.
238+
239+ Command: [ DELETE] ( http://tools.ietf.org/html/rfc3501#section-6.3.4 )
240+
241+ Example
242+
243+ ``` javascript
244+ client .deleteMailbox (' Foo' ).then (() => { ... });
245+ ```
235246
236247## Select mailbox
237248
Original file line number Diff line number Diff line change @@ -572,6 +572,35 @@ describe('browserbox unit tests', () => {
572572 } )
573573 } )
574574
575+ describe ( '#deleteMailbox' , ( ) => {
576+ beforeEach ( ( ) => {
577+ sinon . stub ( br , 'exec' )
578+ } )
579+
580+ it ( 'should call DELETE with a string payload' , ( ) => {
581+ br . exec . withArgs ( {
582+ command : 'DELETE' ,
583+ attributes : [ 'mailboxname' ]
584+ } ) . returns ( Promise . resolve ( ) )
585+
586+ return br . deleteMailbox ( 'mailboxname' ) . then ( ( ) => {
587+ expect ( br . exec . callCount ) . to . equal ( 1 )
588+ } )
589+ } )
590+
591+ it ( 'should call mutf7 encode the argument' , ( ) => {
592+ // From RFC 3501
593+ br . exec . withArgs ( {
594+ command : 'DELETE' ,
595+ attributes : [ '~peter/mail/&U,BTFw-/&ZeVnLIqe-' ]
596+ } ) . returns ( Promise . resolve ( ) )
597+
598+ return br . deleteMailbox ( '~peter/mail/\u53f0\u5317/\u65e5\u672c\u8a9e' ) . then ( ( ) => {
599+ expect ( br . exec . callCount ) . to . equal ( 1 )
600+ } )
601+ } )
602+ } )
603+
575604 describe . skip ( '#listMessages' , ( ) => {
576605 beforeEach ( ( ) => {
577606 sinon . stub ( br , 'exec' )
Original file line number Diff line number Diff line change @@ -359,6 +359,23 @@ export default class Client {
359359 }
360360 }
361361
362+ /**
363+ * Delete a mailbox with the given path.
364+ *
365+ * DELETE details:
366+ * https://tools.ietf.org/html/rfc3501#section-6.3.4
367+ *
368+ * @param {String } path
369+ * The path of the mailbox you would like to delete. This method will
370+ * handle utf7 encoding for you.
371+ * @returns {Promise }
372+ * Promise resolves if mailbox was deleted.
373+ */
374+ deleteMailbox ( path ) {
375+ this . logger . debug ( 'Deleting mailbox' , path , '...' )
376+ return this . exec ( { command : 'DELETE' , attributes : [ imapEncode ( path ) ] } )
377+ }
378+
362379 /**
363380 * Runs FETCH command
364381 *
You can’t perform that action at this time.
0 commit comments