New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ng-on

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-on - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

package.json
{
"name": "ng-on",
"version": "0.0.2",
"version": "0.0.3",
"description": "Directive for Angular 1.x to easily bind custom (or not) events",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -21,3 +21,7 @@ ;(function() {

scope.$evalAsync(function() {
eventsAndCallbacks[eventName](event);
try {
eventsAndCallbacks[eventName](event);
} catch(e) {
throwError(e, eventName);
}
});

@@ -31,3 +35,9 @@ });

function throwError(error, eventName) {
if(error instanceof TypeError) {
throw new Error('handler for event "' + eventName + '" is not a function');
}
}
})();

@@ -0,1 +1,3 @@

/* global jasmine, describe, it, beforeEach, expect, module, inject, createCompiler */
'use strict';

@@ -20,18 +22,42 @@

it('should call defined event handler', function() {
var eventObj = {
click: jasmine.createSpy('clickSpy')
var events = {
click: jasmine.createSpy('clickSpy'),
'the-amazing-spiderman': jasmine.createSpy('the-amazing-spiderman')
};
compile({ events: eventObj }, elementAttrsMock, function (scope, element, driver) {
compile({ events: events }, elementAttrsMock, function (scope, element) {
scope = $rootScope.$new();
element.triggerHandler('click');
element.triggerHandler('the-amazing-spiderman');
scope.$digest();
expect(scope.$parent.$$childHead.events.click).toHaveBeenCalledWith(jasmine.objectContaining({
type: 'click'
}));
expect(scope.$parent.$$childHead.events.click)
.toHaveBeenCalledWith(jasmine.objectContaining({
type: 'click'
}));
expect(scope.$parent.$$childHead.events['the-amazing-spiderman'])
.toHaveBeenCalledWith(jasmine.objectContaining({
type: 'the-amazing-spiderman'
}));
});
});
});
describe('when given incorrect event object', function() {
it('should throw error', function() {
var events = { 'shitsOnFireYo': undefined };
compile({ events: events }, elementAttrsMock, function (scope, element) {
scope = $rootScope.$new();
expect(function() {
element.triggerHandler('shitsOnFireYo');
scope.$digest();
}).toThrow(new Error('handler for event "shitsOnFireYo" is not a function'));
});
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc