-
Notifications
You must be signed in to change notification settings - Fork 0
/
NgDirectiveWithScopeFalse.test.js
47 lines (36 loc) · 1.48 KB
/
NgDirectiveWithScopeFalse.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
describe('Inspector abilities for ngDirective({scope:false}) scope problems', function () {
"use strict";
var $rootScope, $scope, $compile, Inspector, InspectorHelpers, element;
beforeEach(function () {
module('inspector-test-helpers');
module('scope-aware');
});
beforeEach(inject(function (_$rootScope_, _$compile_, _Inspector_, _InspectorHelpers_) {
$rootScope = _$rootScope_;
$compile = _$compile_;
Inspector = _Inspector_;
InspectorHelpers = _InspectorHelpers_;
$scope = $rootScope.$new();
$scope.token = 'a';
element = InspectorHelpers.createDirective('directiveSharedScope', $scope);
}));
afterEach(function() {
console.log(Inspector.inspect($scope));
});
it("doesn't create own scope",function() {
var input = element.find('input')[0];
var scope = angular.element(input).scope();
expect(scope).toBe($scope);
});
it("clobbers the shared properties", function () {
var input = element.find('input')[0];
var scope = angular.element(input).scope();
angular.element(input).val('AAA').triggerHandler('input');
$scope.$digest();
//the value of token is 'AAA' because the directive has overridden the value in the shared scope
expect(scope.token).toBe($scope.token);
expect($scope.token).toBe('AAA');
//additional tests (ng-scope-aware)
expect(scope).toHaveMembers('token');
});
});