Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lvidarte/tests #67

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ pids
logs
results

node_modules
npm-debug.log
*~
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export MOCHA=node_modules/mocha-phantomjs/bin/mocha-phantomjs

all: npm

test: unitary_test

npm:
@npm install

unitary_test:
@echo "Running unitary tests..."
@LOG_LEVEL=error ${MOCHA} --timeout 10000 --reporter spec tests/models/editor.html

.PHONY: clean npm unitary_test
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
"winston" : "0.7.x",
"moment" : "1.7.x"
},
"devDependencies": {
"mocha": "~1.17.1",
"chai": "~1.9.0",
"mocha-phantomjs": "~3.3.2",
"phantomjs": "~1.9.7-1"
},
"scripts": {
"test": "make test"
},
"license": "agplv3",
"engines": {
"node": ">=0.6"
Expand Down
Binary file added tests/models/autobots.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions tests/models/editor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../node_modules/mocha/mocha.css" />
<title>Editor Test Suite</title>
</head>
<body>
<div id="mocha"></div>
<div id="container"></div>
<script src="../../node_modules/mocha/mocha.js"></script>
<script src="../../node_modules/chai/chai.js"></script>
<script>
mocha.ui('bdd');
mocha.reporter('html');
expect = chai.expect;
</script>
<script src="../../vendor/kinetic-v4.5.2.js"></script>
<script src="../../node_modules/underscore/underscore.js"></script>
<script src="../../node_modules/backbone/backbone.js"></script>
<script src="jquery.js"></script>
<script src="../../widgets/WebvfxSimpleWidget.js"></script>
<script src="../../models/Editor.js"></script>
<script src="editor.js"></script>
<script>
if (window.mochaPhantomJS)
mochaPhantomJS.run();
else
mocha.run();
</script>
</body>
</html>
144 changes: 144 additions & 0 deletions tests/models/editor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/* Mocks */
Sketch = {
LiveCollection: function() {},
};

appCollection = {models: [{get: function() {
return {
Widgets: {WeatherWoeid: 54},
General: {fps: 30},
}
}}]};

Blob = function() {};
webkitURL = {
createObjectURL: function() {return 'autobots.png'},
};

Tools = {
getIntValues: function() {
return {width: 10, height: 5, top: 0, left: 0};
},
toCssStyleString: function() {
return '';
},
};
/* end Mocks */


describe("Webvfx Models", function() {

before(function() {
window.webvfxEditor = this.webvfxEditor = new WebvfxEditor({
width: 1920,
height: 1080,
scale: .5,
});
});


describe("WebvfxEditor", function() {

it("The scaled width must be 960", function() {
expect( this.webvfxEditor.getScaledWidth() ).equals(960);
});

it("The scaled height must be 540", function() {
expect( this.webvfxEditor.getScaledHeight() ).equals(540);
});

});

describe("WebvfxImage", function() {

before(function() {
this.webvfxImage = new WebvfxImage({ });
});

it("isImage() must return true", function() {
expect( this.webvfxImage.isImage() ).equals(true);
});

it("isAnimation() must return false", function() {
expect( this.webvfxImage.isAnimation() ).equals(false);
});

});

describe("WebvfxAnimation", function() {

before(function(done) {
var self = this;
var image = new Image();
image.src = 'autobots.png';
image.onload = function() {
self.webvfxAnimation = new WebvfxAnimation({
image: image,
frames: 40,
});
done();
}
});

it("isAnimation() must return true", function(done) {
expect( this.webvfxAnimation.isAnimation() ).equals(true);
done();
});

it("isImage() must return false", function() {
expect( this.webvfxAnimation.isImage() ).equals(false);
});

});

describe("WebvfxWidget", function() {

before(function(done) {
this.webvfxWidget = new WebvfxWidget({
options: {
type: 'text',
style: {},
}
});
done();
});

it("isWidget() must return true", function(done) {
expect( this.webvfxWidget.isWidget() ).equals(true);
done();
});

it("isImage() must return false", function() {
expect( this.webvfxWidget.isImage() ).equals(false);
});

});

describe("WebvfxCollection", function() {

before(function(done) {
window.webvfxCollection = this.webvfxCollection = new WebvfxCollection([
new WebvfxWidget({options: {type: 'text', text: 'two' , style: {}}, zindex: 2}),
new WebvfxWidget({options: {type: 'text', text: 'three', style: {}}, zindex: 3}),
new WebvfxWidget({options: {type: 'text', text: 'one' , style: {}}, zindex: 1})
]);
done();
});

it("webvfxCollection.length must return 3", function(done) {
expect( this.webvfxCollection.length ).equals(3);
done();
});

it("The first element on collection must have text 'one'", function() {
expect( this.webvfxCollection.models[0].getText() ).equals('one');
});

it("The last element on collection must have text 'three'", function() {
expect( this.webvfxCollection.models[2].getText() ).equals('three');
});

});

});

Loading