mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-11 01:33:24 +01:00
unit testing for events
This commit is contained in:
parent
27149b0870
commit
98d9d877a2
@ -56,7 +56,6 @@
|
|||||||
<sourceIncludes>
|
<sourceIncludes>
|
||||||
<include>Functions.js</include>
|
<include>Functions.js</include>
|
||||||
</sourceIncludes>
|
</sourceIncludes>
|
||||||
<browserVersion>CHROME</browserVersion>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.github.searls</groupId>
|
<groupId>com.github.searls</groupId>
|
||||||
<artifactId>jasmine-maven-plugin</artifactId>
|
<artifactId>jasmine-maven-plugin</artifactId>
|
||||||
<version>1.3.1.4</version>
|
<version>1.3.1.5</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
@ -266,12 +266,16 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<!--
|
||||||
<browserVersion>FIREFOX_3_6</browserVersion>
|
<browserVersion>FIREFOX_3_6</browserVersion>
|
||||||
<webDriverClassName>org.openqa.selenium.firefox.FirefoxDriver</webDriverClassName>
|
<webDriverClassName>org.openqa.selenium.firefox.FirefoxDriver</webDriverClassName>
|
||||||
|
|
||||||
|
-->
|
||||||
<sourceIncludes>
|
<sourceIncludes>
|
||||||
<sourceInclude>libraries/mootools/mootools-core-1.4.5-full-nocompat.js</sourceInclude>
|
<include>libraries/mootools/mootools-core-1.4.5-full-nocompat-yc.js</include>
|
||||||
<sourceInclude>header.js</sourceInclude>
|
<include>header.js</include>
|
||||||
|
<include>libraries/jquery/jquery-2.1.0.min.js</include>
|
||||||
|
<include>Events.js</include>
|
||||||
</sourceIncludes>
|
</sourceIncludes>
|
||||||
<specExcludes>
|
<specExcludes>
|
||||||
<exclude>static/test/*.js</exclude>
|
<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