mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-03 03:55:26 +03:00
fix: model_events_spec.js just throws a general event for "everyone"
This commit is contained in:
parent
bdef04bcda
commit
37317db031
@ -1,6 +1,7 @@
|
||||
/*globals describe, before, afterEach, it*/
|
||||
var should = require('should'),
|
||||
sinon = require('sinon'),
|
||||
rewire = require('rewire'),
|
||||
sandbox = sinon.sandbox.create(),
|
||||
events = require('../../server/events'),
|
||||
Models = require('../../server/models');
|
||||
@ -9,7 +10,15 @@ var should = require('should'),
|
||||
should.equal(true, true);
|
||||
|
||||
describe('Model Events', function () {
|
||||
var eventsToRemember = {};
|
||||
|
||||
before(function () {
|
||||
sandbox.stub(events, 'on', function (name, callback) {
|
||||
eventsToRemember[name] = callback;
|
||||
});
|
||||
|
||||
rewire('../../server/models/base/events');
|
||||
|
||||
// Loads all the models
|
||||
Models.init();
|
||||
});
|
||||
@ -22,8 +31,10 @@ describe('Model Events', function () {
|
||||
it('calls User edit when event is emitted', function (done) {
|
||||
// Setup
|
||||
var userModelSpy = sandbox.spy(Models.User, 'edit');
|
||||
|
||||
// Test
|
||||
events.emit('token.added', {get: function () { return 1; }});
|
||||
eventsToRemember['token.added']({get: function () { return 1; }});
|
||||
|
||||
// Assert
|
||||
userModelSpy.calledOnce.should.be.true();
|
||||
userModelSpy.calledWith(
|
||||
|
Loading…
Reference in New Issue
Block a user