B2G/gaia/apps/email/js/ext/mailapi/fake/configurator.js
/**
 * Fake accounts always regenerate from scratch when instantiated; there is
 * no disk persistence.
 *
 * This might be better off being rejiggered to leverage the IMAP account
 * implementation and use some combination of making it think it is
 * permanently offline, manually cramming messages in, and pretending that
 * jobs actually ran on the server.  A mock/fakish IMAP protocol or real
 * protocol talking to a fake socket would likely be too much effort for
 * something likely to be brittle.
 */
Fake accounts always regenerate from scratch when instantiated; there is
no disk persistence.

This might be better off being rejiggered to leverage the IMAP account
implementation and use some combination of making it think it is
permanently offline, manually cramming messages in, and pretending that
jobs actually ran on the server.  A mock/fakish IMAP protocol or real
protocol talking to a fake socket would likely be too much effort for
something likely to be brittle.
Fake accounts always regenerate from scratch when instantiated ; there is no disk persistence . This might be better off being rejiggered to leverage the IMAP account implementation and use some combination of making it think it is permanently offline manually cramming messages in and pretending that jobs actually ran on the server . A mock / fakish IMAP protocol or real protocol talking to a fake socket would likely be too much effort for something likely to be brittle .
function FakeAccount(universe, accountDef, folderInfo, receiveProtoConn, _LOG) {
  this.universe = universe;
  this.id = accountDef.id;
  this.accountDef = accountDef;
  this.enabled = true;
  this.problems = [];
  var generator = new MessageGenerator();
  this.identities = accountDef.identities;
  var ourIdentity = accountDef.identities[0];
  var ourNameAndAddress = {
    name: ourIdentity.name,
    address: ourIdentity.address,
  };
  var HOURS_MS = 60 * 60 * 1000;
  var inboxFolder = {
    id: this.id + '/0',
    name: 'Inbox',
    path: 'Inbox',
    type: 'inbox',
    delim: '/',
    depth: 0,
    lastSyncedAt: Date.now() - 1 * HOURS_MS,
  };
  var todoFolder = {
    id: this.id + '/1',
    name: 'ToDo',
    path: 'Inbox/ToDo',
    type: 'normal',
    delim: '/',
    depth: 1,
    lastSyncedAt: Date.now() - 3 * HOURS_MS,
  };
  var draftsFolder = {
    id: this.id + '/2',
    name: 'Drafts',
    path: 'Drafts',
    type: 'drafts',
    delim: '/',
    depth: 0,
    lastSyncedAt: Date.now() - 75 * HOURS_MS,
  };
  var sentFolder = {
    id: this.id + '/3',
    name: 'Sent',
    path: 'Sent',
    type: 'sent',
    delim: '/',
    depth: 0,
    lastSyncedAt: Date.now() - 29 * HOURS_MS,
  };
  this.folders = [inboxFolder, todoFolder, draftsFolder, sentFolder];
  this._folderStorages = {};
  this._folderStorages[inboxFolder.id] =
    new FakeFolderStorage(
      inboxFolder,
      generator.makeMessages(
        { folderId: inboxFolder.id, count: 16, to: [ourNameAndAddress] }));
  this._folderStorages[todoFolder.id] =
    new FakeFolderStorage(
      todoFolder,
      generator.makeMessages(
        { folderId: todoFolder.id, count: 2, to: [ourNameAndAddress] }));
  this._folderStorages[draftsFolder.id] =
    new FakeFolderStorage(draftsFolder, []);
  this._folderStorages[sentFolder.id] =
    new FakeFolderStorage(
      sentFolder,
      generator.makeMessages(
        { folderId: sentFolder.id, count: 4, from: ourNameAndAddress }));
  this.meta = folderInfo.$meta;
  this.mutations = folderInfo.$mutations;
}
function FakeAccount ( universe , accountDef , folderInfo , receiveProtoConn , _LOG ) { this . universe = universe ; this . id = accountDef . id ; this . accountDef = accountDef ; this . enabled = true ; this . problems = [ ] ; var generator = new MessageGenerator ( ) ; this . identities = accountDef . identities ; var ourIdentity = accountDef . identities [ 0 ] ; var ourNameAndAddress = { name : ourIdentity . name , address : ourIdentity . address , } ; var HOURS_MS = 60 * 60 * 1000 ; var inboxFolder = { id : this . id + '/0' , name : 'Inbox' , path : 'Inbox' , type : 'inbox' , delim : '/' , depth : 0 , lastSyncedAt : Date . now ( ) - 1 * HOURS_MS , } ; var todoFolder = { id : this . id + '/1' , name : 'ToDo' , path : 'Inbox/ToDo' , type : 'normal' , delim : '/' , depth : 1 , lastSyncedAt : Date . now ( ) - 3 * HOURS_MS , } ; var draftsFolder = { id : this . id + '/2' , name : 'Drafts' , path : 'Drafts' , type : 'drafts' , delim : '/' , depth : 0 , lastSyncedAt : Date . now ( ) - 75 * HOURS_MS , } ; var sentFolder = { id : this . id + '/3' , name : 'Sent' , path : 'Sent' , type : 'sent' , delim : '/' , depth : 0 , lastSyncedAt : Date . now ( ) - 29 * HOURS_MS , } ; this . folders = [ inboxFolder , todoFolder , draftsFolder , sentFolder ] ; this . _folderStorages = { } ; this . _folderStorages [ inboxFolder . id ] = new FakeFolderStorage ( inboxFolder , generator . makeMessages ( { folderId : inboxFolder . id , count : 16 , to : [ ourNameAndAddress ] } ) ) ; this . _folderStorages [ todoFolder . id ] = new FakeFolderStorage ( todoFolder , generator . makeMessages ( { folderId : todoFolder . id , count : 2 , to : [ ourNameAndAddress ] } ) ) ; this . _folderStorages [ draftsFolder . id ] = new FakeFolderStorage ( draftsFolder , [ ] ) ; this . _folderStorages [ sentFolder . id ] = new FakeFolderStorage ( sentFolder , generator . makeMessages ( { folderId : sentFolder . id , count : 4 , from : ourNameAndAddress } ) ) ; this . meta = folderInfo . $meta ; this . mutations = folderInfo . $mutations ; }
Fake accounts always regenerate from scratch when instantiated; there is
 no disk persistence.
Fake accounts always regenerate from scratch when instantiated ; there is no disk persistence .