Closed Bug 1016407 Opened 8 years ago Closed 8 years ago

[Calendar] Fix unit tests with a newer mocha


(Firefox OS Graveyard :: Gaia::Calendar, defect)

Not set


(Not tracked)



(Reporter: julienw, Assigned: julienw)




(1 file)

46 bytes, text/x-github-pull-request
: review+
Details | Review
In Bug 874510, we try to upgrade mocha and we faced some issues in existing tests.

In Calendar, here are the failing tests:

  1) [calendar-test/unit/store/abstract_test.js] store/abstract #persist "before each" hook: wrapper:
     TypeError: invalid 'in' operand data
      at _objectData (
      at persist (
      at (anonymous) (
      at wrapper (
      at run (
      at next (
      at (anonymous) (
      at timeslice (

  2) [calendar-test/unit/controllers/alarm_test.js] Controllers.Alarm "after each" hook: wrapper:
     Uncaught Error: TypeError: mockAlarms.onadd is not a function (
      at onerror (

  3) [calendar-test/unit/views/month_test.js] Views.Month #_onswipe:
     Error: selects first day of month: expected undefined to equal Thu, 31 May 2012 22:00:00 GMT
      at chaiAssert (
      at eql (
      at deepEqual (
      at (anonymous) (
      at wrapper (
      at run (
      at runTest (
      at (anonymous) (
      at next (
      at (anonymous) (
      at next (
      at (anonymous) (
      at done (
      at (anonymous) (
      at (anonymous) (
      at wrapper (
      at run (
      at next (
      at (anonymous) (
      at timeslice (

  4) [calendar-test/unit/app_test.js] app PendingManager event life-cycle multiple events:
     Uncaught Error: Error: expected { app: 
   { PendingManager: [Function: PendingManager],
     DateL10n: { localizeElements: [Function], localizeElement: [Function] },
     startingURL: '',
     _location: {},
     _mozTimeRefreshTimeout: 3000,
     pendingClass: 'pending-operation',
     configure: [Function],
     observeDateLocalization: [Function],
     observePendingObject: [Function],
     isPending: [Function],
     loadObject: [Function: initializeLoadObject],
     forceRestart: [Function],
     go: [Function],
     state: [Function],
     modifier: [Function],
     resetState: [Function],
     _routes: [Function],
     _init: [Function],
     _showTodayDate: [Function],
     _syncTodayDate: [Function],
     init: [Function],
     provider: [Function],
     _initView: [Function],
     view: [Function],
     store: [Function],
     offline: [Function],
      { name: 'b2g-test-calendar',
        _stores: [Object],
        '_$events': {},
        _upgradeOperations: [] },
      { page: [Object],
        _activeObjects: [],
        start: [Function],
        stop: [Function],
        show: [Function],
        _lastState: [Function] },
     _providers: {},
     _views: {},
     _routeViewFn: {},
      { objects: [Object],
        pending: 0,
        onstart: [Function],
        onend: [Function],
        oncomplete: [Function: onpending],
        onpending: [Function: oncomplete] },
      { app: [Circular],
        '_$events': {},
        _timeObservers: [],
        _timeCache: {},
        _eventsCache: {},
        _timespans: [],
        _collection: [Object],
        busytime: [Object] },
     syncController: { app: [Circular], pending: 0, '_$events': [Object] },
     serviceController: { _lastId: 0, '_$events': {}, roles: {}, workers: [] },
     alarmController: { app: [Circular], store: [Object] },
     errorController: { '_$events': {}, app: [Circular], _handlers: {} },
      { localeDateString: [Function: localeDateString],
        localeTimeString: [Function: localeTimeString],
        localeString: [Function: localeString],
        localeFormat: [Function: localeFormat],
        fromNow: [Function: prettyDate],
        relativeParts: [Function: relativeParts] } },
  called: 1,
  args: { '0': { app: [Object] } },
  onactive: [Function],
  oninactive: [Function] } to equal undefined (
      at onerror (

  5) [calendar-test/unit/app_test.js]  "after each" hook: wrapper:
     TypeError: this.sinon is null
      at (anonymous) (
      at wrapper (
      at run (
      at next (
      at (anonymous) (
      at timeslice (

  6) [calendar-test/unit/app_test.js]  "after each" hook: wrapper:
     TypeError: this.sinon is null
      at (anonymous) (
      at wrapper (
      at run (
      at next (
      at (anonymous) (
      at timeslice (
Blocks: 1016410
No longer blocks: 1016410
For some reason, the only one remaining is the first one, which is an easy one and comes from the fact that "this" is not the same object in nested suites now. I'll have a patch ready shortly.
Assignee: nobody → felash
Attached file github PR
Hey James,

Hope you'll have the time to check this.

The issue is that with the new mocha, nested suites use a new context whose prototype is the parent suite's context. I could probably have used something like `this.constructor.prototype` but this fix looks simpler.
Attachment #8441330 - Flags: review?(jlal)
Closed: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.