diff --git a/test/res/external-svg.svg b/test/res/external-svg.svg
new file mode 100644
index 0000000..f3c2d62
--- /dev/null
+++ b/test/res/external-svg.svg
@@ -0,0 +1,4 @@
+
+
\ No newline at end of file
diff --git a/test/savage-tests.js b/test/savage-tests.js
index 071d4d7..65f5760 100644
--- a/test/savage-tests.js
+++ b/test/savage-tests.js
@@ -49,4 +49,196 @@ describe("Savage methods", function () {
}, {'isContext': true});
expect(xhr).to.be.an('object');
});
+
+ var validateMina = function(minaObj) {
+ expect(minaObj).to.be.an('object');
+ expect(minaObj.id).to.be.a('string');
+ expect(minaObj.duration).to.be.a('function');
+ expect(minaObj.easing).to.be.a('function');
+ expect(minaObj.speed).to.be.a('function');
+ expect(minaObj.status).to.be.a('function');
+ expect(minaObj.stop).to.be.a('function');
+ };
+
+ it("Savage.animate - numbers, no easing or callback", function(done) {
+ var n;
+ var minaObj = Savage.animate(10, 20, function(newN) { n = newN; }, 50);
+ setTimeout(function() {
+ expect(n).to.be(20);
+ done();
+ }, 100);
+ validateMina(minaObj);
+ });
+ it("Savage.animate - numbers, callback", function(done) {
+ var n;
+ var minaObj = Savage.animate(10, 20, function(newN) { n = newN; }, 50, function() {
+ expect(n).to.be(20);
+ done();
+ });
+ validateMina(minaObj);
+ });
+ it("Savage.animate - numbers, easing", function(done) {
+ var n;
+ var minaObj = Savage.animate(10, 20, function(newN) { n = newN; }, 50, mina.easeinout);
+ setTimeout(function() {
+ expect(n).to.be(20);
+ done();
+ }, 100);
+ validateMina(minaObj);
+ });
+ it("Savage.animate - numbers, easing & callback", function(done) {
+ var n;
+ var minaObj = Savage.animate(10, 20, function(newN) { n = newN; }, 50, mina.bounce, function() {
+ expect(n).to.be(20);
+ done();
+ });
+ validateMina(minaObj);
+ });
+ it("Savage.animate - arrays, no easing or callback", function(done) {
+ var n1, n2;
+ var minaObj = Savage.animate([5, 10], [10, 20], function(nArr) { n1 = nArr[0]; n2 = nArr[1]; }, 50);
+ setTimeout(function() {
+ expect(n1).to.be(10);
+ expect(n2).to.be(20);
+ done();
+ }, 100);
+ validateMina(minaObj);
+ });
+ it("Savage.animate - arrays, callback", function(done) {
+ var n1, n2;
+ var minaObj = Savage.animate([5, 10], [10, 20], function(nArr) {n1 = nArr[0]; n2 = nArr[1]; }, 50, function() {
+ expect(n1).to.be(10);
+ expect(n2).to.be(20);
+ done();
+ });
+ validateMina(minaObj);
+ });
+ it("Savage.animate - arrays, easing", function(done) {
+ var n1, n2;
+ var minaObj = Savage.animate([5, 10], [10, 20], function(nArr) { n1 = nArr[0], n2 = nArr[1]; }, 50, mina.easeinout);
+ setTimeout(function() {
+ expect(n1).to.be(10);
+ expect(n2).to.be(20);
+ done();
+ }, 100);
+ validateMina(minaObj);
+ });
+ it("Savage.animate - arrays, easing & callback", function(done) {
+ var n1, n2;
+ var minaObj = Savage.animate([5, 10], [10, 20], function(nArr) { n1 = nArr[0], n2 = nArr[1] }, 50, mina.backin, function() {
+ expect(n1).to.be(10);
+ expect(n2).to.be(20);
+ done();
+ });
+ validateMina(minaObj);
+ });
+ it("Savage.animation - no easing or callback", function() {
+ var anim = Savage.animation({ foo: "bar" }, 100);
+ expect(anim).to.be.an("object");
+ expect(anim.dur).to.be(100);
+ expect(anim.attr.foo).to.be("bar");
+ });
+ it("Savage.animation - with easing", function() {
+ var anim = Savage.animation({ foo: "bar" }, 100, mina.easein);
+ expect(anim).to.be.an("object");
+ expect(anim.dur).to.be(100);
+ expect(anim.attr.foo).to.be("bar");
+ expect(anim.easing).to.be.a("function");
+ });
+ it("Savage.animation - with callback", function() {
+ var cb = function(){};
+ var anim = Savage.animation({ foo: "bar" }, 100, cb);
+ expect(anim).to.be.an("object");
+ expect(anim.dur).to.be(100);
+ expect(anim.attr.foo).to.be("bar");
+ expect(anim.callback).to.be.a("function");
+ });
+ it("Savage.animation - with easing & callback", function() {
+ var cb = function(){};
+ var anim = Savage.animation({ foo: "bar" }, 100, mina.linear, cb);
+ expect(anim).to.be.an("object");
+ expect(anim.dur).to.be(100);
+ expect(anim.attr.foo).to.be("bar");
+ expect(anim.easing).to.be.a("function");
+ expect(anim.callback).to.be.a("function");
+ expect(anim.easing).to.not.be(anim.callback);
+ });
+ it("Savage.deg", function() {
+ expect(Savage.deg(Math.PI)).to.be(180);
+ expect(Savage.deg(Math.PI / 2)).to.be(90);
+ expect(Savage.deg(Math.PI / 4)).to.be(45)
+ expect(Savage.deg(Math.PI * 2)).to.be(0);
+ });
+ it("Savage.rad", function() {
+ expect(Savage.rad(180)).to.be(Math.PI);
+ expect(Savage.rad(90)).to.be(Math.PI / 2);
+ expect(Savage.rad(45)).to.be(Math.PI / 4);
+ expect(Savage.rad(0)).to.be(0);
+ });
+ it("Savage.format", function() {
+ var outputStr;
+ outputStr = Savage.format("{x}", {x: 1});
+ expect(outputStr).to.be("1");
+ outputStr = Savage.format("{a['foo']}", {
+ a: {
+ foo: 'bar'
+ }
+ });
+ expect(outputStr).to.be("bar");
+ outputStr = Savage.format("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width']}z", {
+ x: 10,
+ y: 20,
+ dim: {
+ width: 40,
+ height: 50,
+ "negative width": -40
+ }
+ });
+ expect(outputStr).to.be("M10,20h40v50h-40z");
+ });
+ it("Savage.fragment", function() {
+ var frag = Savage.fragment('', '');
+ expect(frag).to.be.an("object");
+ expect(frag.node.childNodes.length).to.be(2);
+ expect(frag.node.firstChild.nodeName).to.be("g");
+ expect(frag.node.firstChild.getAttribute("class")).to.be("foo");
+ expect(frag.node.lastChild.getAttribute("class")).to.be("foo2");
+ frag = Savage.fragment('');
+ var rectWidth = frag.select('rect').attr('width');
+ expect(rectWidth).to.be("10");
+ });
+ it("Savage.is", function() {
+ var undef;
+ expect(Savage.is("foo", "string")).to.be.ok();
+ expect(Savage.is(123, "number")).to.be.ok();
+ expect(Savage.is({}, "object")).to.be.ok();
+ expect(Savage.is([], "array")).to.be.ok();
+ expect(Savage.is(null, "null")).to.be.ok();
+ expect(Savage.is(false, "boolean")).to.be.ok();
+ expect(Savage.is(undef, "undefined")).to.be.ok();
+ expect(Savage.is(function(){}, "function")).to.be.ok();
+ });
+ it("Savage.load - with context", function(done) {
+ Savage.load('./res/external-svg.svg', function(fragment) {
+ expect(fragment.node.firstElementChild.nodeName).to.be('svg');
+ expect(this.myContext).to.be(true);
+ done();
+ }, {myContext: true});
+ });
+ it("Savage.load - without context", function(done) {
+ Savage.load('./res/external-svg.svg', function(fragment) {
+ expect(fragment.node.firstElementChild.nodeName).to.be('svg');
+ done();
+ });
+ });
+ it("Savage.parse", function() {
+ var frag = Savage.parse('');
+ expect(frag).to.be.an("object");
+ expect(frag.node.childNodes.length).to.be(1);
+ expect(frag.node.firstChild.nodeName).to.be("g");
+ expect(frag.node.firstChild.getAttribute("class")).to.be("foo");
+ frag = Savage.parse('');
+ var rectWidth = frag.select('rect').attr('width');
+ expect(rectWidth).to.be("10");
+ });
});
\ No newline at end of file