Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 0cc75be

Browse files
committed
test(introspection): work around issue 1219
Ref: #1219
1 parent 0ba335d commit 0cc75be

File tree

1 file changed

+64
-61
lines changed

1 file changed

+64
-61
lines changed

test/introspection_spec.dart

+64-61
Original file line numberDiff line numberDiff line change
@@ -89,76 +89,79 @@ void main() {
8989
expect(js.context['ngProbe'].apply([ngtop])).toBeDefined();
9090
});
9191

92-
describe(r'testability', () {
93-
var testability;
92+
// Issue #1219
93+
if (identical(1, 1.0) || !js.context['DART_VERSION'].toString().contains("version: 1.5.")) {
94+
describe(r'testability', () {
95+
var testability;
9496

95-
beforeEach(() {
96-
testability = angular['getTestability'].apply([ngtop]);
97-
});
97+
beforeEach(() {
98+
testability = angular['getTestability'].apply([ngtop]);
99+
});
98100

99-
it('should be available from Javascript', () {
100-
expect(testability).toBeDefined();
101-
});
101+
it('should be available from Javascript', () {
102+
expect(testability).toBeDefined();
103+
});
102104

103-
it('should expose allowAnimations', () {
104-
allowAnimations(allowed) => testability['allowAnimations'].apply([allowed]);
105-
expect(allowAnimations(false)).toEqual(true);
106-
expect(allowAnimations(false)).toEqual(false);
107-
expect(allowAnimations(true)).toEqual(false);
108-
expect(allowAnimations(true)).toEqual(true);
109-
});
105+
it('should expose allowAnimations', () {
106+
allowAnimations(allowed) => testability['allowAnimations'].apply([allowed]);
107+
expect(allowAnimations(false)).toEqual(true);
108+
expect(allowAnimations(false)).toEqual(false);
109+
expect(allowAnimations(true)).toEqual(false);
110+
expect(allowAnimations(true)).toEqual(true);
111+
});
112+
113+
describe('bindings', () {
114+
it('should find exact bindings', () {
115+
// exactMatch should fail.
116+
var bindingNodes = testability['findBindings'].apply(['introspection', true]);
117+
expect(bindingNodes.length).toEqual(0);
118+
119+
// substring search (default) should succeed.
120+
// exactMatch should default to false.
121+
bindingNodes = testability['findBindings'].apply(['introspection']);
122+
expect(bindingNodes.length).toEqual(1);
123+
bindingNodes = testability['findBindings'].apply(['introspection', false]);
124+
expect(bindingNodes.length).toEqual(1);
125+
126+
// and so should exact search with the correct query.
127+
bindingNodes = testability['findBindings'].apply(["'introspection FTW'", true]);
128+
expect(bindingNodes.length).toEqual(1);
129+
});
130+
131+
_assertBinding(String query) {
132+
var bindingNodes = testability['findBindings'].apply([query]);
133+
expect(bindingNodes.length).toEqual(1);
134+
var node = bindingNodes[0];
135+
var probe = js.context['ngProbe'].apply([node]);
136+
expect(probe).toBeDefined();
137+
var bindings = probe['bindings'];
138+
expect(bindings['length']).toEqual(1);
139+
expect(bindings[0].contains(query)).toBe(true);
140+
}
141+
142+
it('should find ng-bind bindings', () => _assertBinding('introspection FTW'));
143+
it('should find attribute mustache bindings', () => _assertBinding('attrMustache'));
144+
it('should find text mustache bindings', () => _assertBinding('textMustache'));
145+
});
110146

111-
describe('bindings', () {
112-
it('should find exact bindings', () {
147+
it('should find models', () {
113148
// exactMatch should fail.
114-
var bindingNodes = testability['findBindings'].apply(['introspection', true]);
115-
expect(bindingNodes.length).toEqual(0);
149+
var modelNodes = testability['findModels'].apply(['my', true]);
150+
expect(modelNodes.length).toEqual(0);
116151

117152
// substring search (default) should succeed.
118-
// exactMatch should default to false.
119-
bindingNodes = testability['findBindings'].apply(['introspection']);
120-
expect(bindingNodes.length).toEqual(1);
121-
bindingNodes = testability['findBindings'].apply(['introspection', false]);
122-
expect(bindingNodes.length).toEqual(1);
123-
124-
// and so should exact search with the correct query.
125-
bindingNodes = testability['findBindings'].apply(["'introspection FTW'", true]);
126-
expect(bindingNodes.length).toEqual(1);
127-
});
128-
129-
_assertBinding(String query) {
130-
var bindingNodes = testability['findBindings'].apply([query]);
131-
expect(bindingNodes.length).toEqual(1);
132-
var node = bindingNodes[0];
133-
var probe = js.context['ngProbe'].apply([node]);
153+
modelNodes = testability['findModels'].apply(['my']);
154+
expect(modelNodes.length).toEqual(1);
155+
var divElement = modelNodes[0];
156+
expect(divElement is DivElement).toEqual(true);
157+
var probe = js.context['ngProbe'].apply([divElement]);
134158
expect(probe).toBeDefined();
135-
var bindings = probe['bindings'];
136-
expect(bindings['length']).toEqual(1);
137-
expect(bindings[0].contains(query)).toBe(true);
138-
}
139-
140-
it('should find ng-bind bindings', () => _assertBinding('introspection FTW'));
141-
it('should find attribute mustache bindings', () => _assertBinding('attrMustache'));
142-
it('should find text mustache bindings', () => _assertBinding('textMustache'));
143-
});
144-
145-
it('should find models', () {
146-
// exactMatch should fail.
147-
var modelNodes = testability['findModels'].apply(['my', true]);
148-
expect(modelNodes.length).toEqual(0);
149-
150-
// substring search (default) should succeed.
151-
modelNodes = testability['findModels'].apply(['my']);
152-
expect(modelNodes.length).toEqual(1);
153-
var divElement = modelNodes[0];
154-
expect(divElement is DivElement).toEqual(true);
155-
var probe = js.context['ngProbe'].apply([divElement]);
156-
expect(probe).toBeDefined();
157-
var models = probe['models'];
158-
expect(models['length']).toEqual(1);
159-
expect(models[0]).toEqual('myModel');
159+
var models = probe['models'];
160+
expect(models['length']).toEqual(1);
161+
expect(models[0]).toEqual('myModel');
162+
});
160163
});
161-
});
164+
}
162165
});
163166
});
164167
}

0 commit comments

Comments
 (0)