1
0
Fork 0

Made domObserver tests work with PhantomJS. Added to automatic tests

This commit is contained in:
Michael Hackstein 2013-11-28 09:48:03 +01:00
parent fed5b288e5
commit 4ec105f5e9
3 changed files with 15 additions and 4 deletions

View File

@ -35,6 +35,9 @@ function DomObserverFactory() {
var Constructor = window.WebKitMutationObserver || window.MutationObserver;
this.createObserver = function(callback) {
if (!Constructor) {
throw "Observer not supported";
}
return new Constructor(callback);
};
}
}

View File

@ -172,7 +172,7 @@ module.exports = function(karma) {
// GraphViewer
'test/specs/graphViewer/specColourMapper/colourMapperSpec.js',
// 'test/specs/graphViewer/specWindowObjects/domObserverFactorySpec.js',
'test/specs/graphViewer/specWindowObjects/domObserverFactorySpec.js',
'test/specs/graphViewer/specCommunityNode/communityNodeSpec.js',
'test/specs/graphViewer/specAdapter/interfaceSpec.js',
'test/specs/graphViewer/specAdapter/abstractAdapterSpec.js',

View File

@ -42,8 +42,16 @@
it('should create a Mutation Observer Instance', function() {
// First is Firefox, Second is Chrome and Safari
var Observer = window.MutationObserver || window.WebKitMutationObserver,
factory = new DomObserverFactory();
expect(factory.createObserver(function() {})).toEqual(jasmine.any(Observer));
factory = new DomObserverFactory(),
agent = window.navigator.userAgent;
if (agent.match(/PhantomJS/)) {
// Fake for PhantomJS. Should not be reached for other browsers
expect(function() {
factory.createObserver(function() {});
}).toThrow("Observer not supported");
return;
}
expect(factory.createObserver(function() {})).toEqual(jasmine.any(Observer));
});
it('should propagate the callback to the MutationObserver', function() {