ng-directive-compiler-helper
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "ng-directive-compiler-helper", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"authors": [ | ||
@@ -21,6 +21,4 @@ "Arijus Šukys <argshook@gmail.com>" | ||
"angular-mocks": "~1.4.7", | ||
"lodash": "~3.10.1", | ||
"angular": "~1.4.7", | ||
"jquery": "~2.1.4" | ||
"angular": "~1.4.7" | ||
} | ||
} |
@@ -0,1 +1,3 @@ | ||
/* global angular */ | ||
'use strict'; | ||
@@ -20,3 +22,3 @@ | ||
var args = Array.prototype.slice.call(arguments, 0), | ||
callback = _.isFunction(_.last(args)) ? args.pop() : angular.noop, | ||
callback = angular.isFunction(args[args.length - 1]) ? args.pop() : angular.noop, | ||
parentScope = args.shift() || {}, | ||
@@ -26,4 +28,4 @@ attrs = args.shift() || {}; | ||
var scope = $rootScope.$new(), | ||
extendedScope = _.extend(scope, parentScope), | ||
templateWithAttrs = $(template).attr(attrs), | ||
extendedScope = angular.extend(scope, parentScope), | ||
templateWithAttrs = angular.element(template).attr(attrs), | ||
element = $compile(templateWithAttrs)(extendedScope); | ||
@@ -30,0 +32,0 @@ |
{ | ||
"name": "ng-directive-compiler-helper", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "helper function for easier angularJS 1.x directive compilation in unit tests", | ||
@@ -27,3 +27,6 @@ "main": "lib/ng-directive-compiler-helper.js", | ||
"phantomjs": "^1.9.18" | ||
}, | ||
"dependencies": { | ||
"bower": "^1.5.3" | ||
} | ||
} |
@@ -0,1 +1,3 @@ | ||
[![Build Status](https://travis-ci.org/argshook/ng-directive-compiler-helper.svg?branch=master)](https://travis-ci.org/argshook/ng-directive-compiler-helper) | ||
# Helper for easier directive compiling | ||
@@ -96,4 +98,5 @@ | ||
// first param === parentScope, empty in this case | ||
compile({}, { newAttribute: 'hello' }, (scope, element) => { | ||
expect(element.attr('newAttribute')).toBe('hello'); | ||
// note that attribute properties are kebab-case and not camelCase! | ||
compile({}, { 'new-attribute': 'hello' }, (scope, element) => { | ||
expect(element.attr('new-attribute')).toBe('hello'); | ||
}); | ||
@@ -100,0 +103,0 @@ }); |
@@ -89,4 +89,5 @@ describe('createCompiler', function() { | ||
it('should set directive attributes from second argument', function() { | ||
createdCompiler({}, { moustache: 'french' }, function(scope, element) { | ||
createdCompiler({}, { moustache: 'french', 'big-phat': 'azz' }, function(scope, element) { | ||
expect(element.attr('moustache')).toBe('french'); | ||
expect(element.attr('big-phat')).toBe('azz'); | ||
}); | ||
@@ -93,0 +94,0 @@ }); |
Sorry, the diff of this file is not supported yet
16190
8
116
1
+ Addedbower@^1.5.3
+ Addedbower@1.8.14(transitive)