mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-12-24 12:13:49 +01:00
unit testing for events
This commit is contained in:
parent
27149b0870
commit
98d9d877a2
@ -56,7 +56,6 @@
|
||||
<sourceIncludes>
|
||||
<include>Functions.js</include>
|
||||
</sourceIncludes>
|
||||
<browserVersion>CHROME</browserVersion>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
@ -257,7 +257,7 @@
|
||||
<plugin>
|
||||
<groupId>com.github.searls</groupId>
|
||||
<artifactId>jasmine-maven-plugin</artifactId>
|
||||
<version>1.3.1.4</version>
|
||||
<version>1.3.1.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@ -266,12 +266,16 @@
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<!--
|
||||
<browserVersion>FIREFOX_3_6</browserVersion>
|
||||
<webDriverClassName>org.openqa.selenium.firefox.FirefoxDriver</webDriverClassName>
|
||||
|
||||
-->
|
||||
<sourceIncludes>
|
||||
<sourceInclude>libraries/mootools/mootools-core-1.4.5-full-nocompat.js</sourceInclude>
|
||||
<sourceInclude>header.js</sourceInclude>
|
||||
<include>libraries/mootools/mootools-core-1.4.5-full-nocompat-yc.js</include>
|
||||
<include>header.js</include>
|
||||
<include>libraries/jquery/jquery-2.1.0.min.js</include>
|
||||
<include>Events.js</include>
|
||||
</sourceIncludes>
|
||||
<specExcludes>
|
||||
<exclude>static/test/*.js</exclude>
|
||||
|
43
mindplot/src/test/javascript/EventsTestSuite.js
Normal file
43
mindplot/src/test/javascript/EventsTestSuite.js
Normal file
@ -0,0 +1,43 @@
|
||||
var TestClass = new Class({
|
||||
Extends: mindplot.Events,
|
||||
|
||||
getEvents: function() {
|
||||
return this.$events;
|
||||
},
|
||||
|
||||
removeEvents: function() {
|
||||
this.$events = {};
|
||||
}
|
||||
});
|
||||
|
||||
// Test class and variables
|
||||
var expectedChangeFn1 = function () {return 'change1';};
|
||||
var expectedChangeFn2 = function () {return 'change2';};
|
||||
var expectedLoadFn = function() {return 'loaded';};
|
||||
var myTestClass = new TestClass();
|
||||
|
||||
|
||||
describe("Events class suite", function() {
|
||||
|
||||
afterEach(function() {
|
||||
myTestClass.removeEvents();
|
||||
});
|
||||
|
||||
it("addEventTest", function() {
|
||||
expect(myTestClass.getEvents()).toEqual({});
|
||||
myTestClass.addEvent('change', expectedChangeFn1);
|
||||
expect(myTestClass.getEvents()).toEqual({change: [expectedChangeFn1]});
|
||||
myTestClass.addEvent('change', expectedChangeFn2);
|
||||
expect(myTestClass.getEvents()).toEqual({change: [expectedChangeFn1, expectedChangeFn2]});
|
||||
myTestClass.addEvent('load', expectedLoadFn);
|
||||
expect(myTestClass.getEvents()).toEqual({change: [expectedChangeFn1, expectedChangeFn2], load: [expectedLoadFn]});
|
||||
});
|
||||
it("removeEventTest", function() {
|
||||
expect(myTestClass.getEvents()).toEqual({});
|
||||
myTestClass.addEvent('change', expectedChangeFn1);
|
||||
myTestClass.addEvent('change', expectedChangeFn2);
|
||||
expect(myTestClass.getEvents()).toEqual({change: [expectedChangeFn1, expectedChangeFn2]});
|
||||
myTestClass.removeEvent('change', expectedChangeFn1);
|
||||
expect(myTestClass.getEvents()).toEqual({change: [expectedChangeFn2]});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user