Closed Bug 1016407 Opened 7 years ago Closed 7 years ago

[Calendar] Fix unit tests with a newer mocha

Categories

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

x86_64
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: julienw, Assigned: julienw)

References

Details

Attachments

(1 file)

46 bytes, text/x-github-pull-request
jlal
: 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 (http://calendar.gaiamobile.org:8080/js/store/abstract.js:374:1)
      at persist (http://calendar.gaiamobile.org:8080/js/store/abstract.js:93:11)
      at (anonymous) (http://calendar.gaiamobile.org:8080/test/unit/store/abstract_test.js:122:9)
      at wrapper (http://calendar.gaiamobile.org:8080/common/test/mocha_generators.js:60:13)
      at run (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4311:7)
      at next (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4613:5)
      at (anonymous) (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4630:5)
      at timeslice (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:5763:5)
  

  2) [calendar-test/unit/controllers/alarm_test.js] Controllers.Alarm "after each" hook: wrapper:
     Uncaught Error: TypeError: mockAlarms.onadd is not a function (http://calendar.gaiamobile.org:8080/test/unit/controllers/alarm_test.js?time=1401204475635:121)
      at onerror (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:5738:7)
  

  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 (http://calendar.gaiamobile.org:8080/common/test/helper.js:33:1)
      at eql (http://calendar.gaiamobile.org:8080/common/vendor/chai/chai.js:530:1)
      at deepEqual (http://calendar.gaiamobile.org:8080/common/vendor/chai/chai.js:1331:5)
      at (anonymous) (http://calendar.gaiamobile.org:8080/test/unit/views/month_test.js:157:1)
      at wrapper (http://calendar.gaiamobile.org:8080/common/test/mocha_generators.js:62:13)
      at run (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4311:7)
      at runTest (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4728:5)
      at (anonymous) (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4806:7)
      at next (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4653:7)
      at (anonymous) (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4663:7)
      at next (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4601:16)
      at (anonymous) (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4625:7)
      at done (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4300:5)
      at (anonymous) (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4314:9)
      at (anonymous) (http://calendar.gaiamobile.org:8080/common/test/mocha_generators.js:46:13)
      at wrapper (http://calendar.gaiamobile.org:8080/common/test/mocha_generators.js:73:15)
      at run (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4311:7)
      at next (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4613:5)
      at (anonymous) (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4630:5)
      at timeslice (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:5763:5)
  

  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: 'http://calendar.gaiamobile.org:8080/test/unit/_sandbox.html?time=1401204531170',
     _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],
     db: 
      { name: 'b2g-test-calendar',
        _stores: [Object],
        '_$events': {},
        _upgradeOperations: [] },
     router: 
      { page: [Object],
        _activeObjects: [],
        start: [Function],
        stop: [Function],
        show: [Function],
        _lastState: [Function] },
     _providers: {},
     _views: {},
     _routeViewFn: {},
     _pendingManger: 
      { objects: [Object],
        pending: 0,
        onstart: [Function],
        onend: [Function],
        oncomplete: [Function: onpending],
        onpending: [Function: oncomplete] },
     timeController: 
      { 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: {} },
     dateFormat: 
      { 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 (http://calendar.gaiamobile.org:8080/common/test/helper.js?time=1401204531284:33)
      at onerror (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:5738:7)
  

  5) [calendar-test/unit/app_test.js]  "after each" hook: wrapper:
     TypeError: this.sinon is null
      at (anonymous) (http://calendar.gaiamobile.org:8080/common/test/sinon_helper.js:8:5)
      at wrapper (http://calendar.gaiamobile.org:8080/common/test/mocha_generators.js:62:13)
      at run (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4311:7)
      at next (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4613:5)
      at (anonymous) (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4630:5)
      at timeslice (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:5763:5)
  

  6) [calendar-test/unit/app_test.js]  "after each" hook: wrapper:
     TypeError: this.sinon is null
      at (anonymous) (http://calendar.gaiamobile.org:8080/common/test/sinon_helper.js:8:5)
      at wrapper (http://calendar.gaiamobile.org:8080/common/test/mocha_generators.js:62:13)
      at run (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4311:7)
      at next (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4613:5)
      at (anonymous) (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:4630:5)
      at timeslice (http://calendar.gaiamobile.org:8080/common/vendor/mocha/mocha.js:5763:5)
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)
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.