mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-10 22:54:24 +02:00
Move tests into src/js/__tests__
This commit is contained in:
parent
dfecf68690
commit
4331e4a981
11 changed files with 13 additions and 13 deletions
82
src/js/__tests__/animation.spec.js
Normal file
82
src/js/__tests__/animation.spec.js
Normal file
|
@ -0,0 +1,82 @@
|
|||
var AnimationModule = require('../visuals/animation/index');
|
||||
var PromiseAnimation = AnimationModule.PromiseAnimation;
|
||||
var Animation = AnimationModule.Animation;
|
||||
var Q = require('q');
|
||||
|
||||
describe('Promise animation', function() {
|
||||
it('Will execute the closure', function() {
|
||||
var value = 0;
|
||||
var closure = function() {
|
||||
value++;
|
||||
};
|
||||
|
||||
var animation = new PromiseAnimation({
|
||||
deferred: Q.defer(),
|
||||
closure: closure
|
||||
});
|
||||
animation.play();
|
||||
expect(value).toBe(1);
|
||||
});
|
||||
|
||||
it('also takes animation packs', function() {
|
||||
var value = 0;
|
||||
var animation = new PromiseAnimation({
|
||||
animation: function() { value++; }
|
||||
});
|
||||
animation.play();
|
||||
expect(value).toBe(1);
|
||||
});
|
||||
|
||||
it('Will resolve a deferred', function() {
|
||||
var value = 0;
|
||||
var closure = function() {
|
||||
value++;
|
||||
};
|
||||
|
||||
var animation = new PromiseAnimation({
|
||||
closure: closure
|
||||
});
|
||||
animation
|
||||
.then(function() {
|
||||
value++;
|
||||
})
|
||||
.then(function() {
|
||||
if (value !== 2) {
|
||||
console.log('second promise failed!!');
|
||||
} else {
|
||||
console.log('1 more test passed');
|
||||
}
|
||||
// TODO -- make this work (aka the tests keep running until
|
||||
// this assertion finishes
|
||||
expect(value).toBe(2);
|
||||
});
|
||||
|
||||
animation.play();
|
||||
expect(value).toBe(1);
|
||||
});
|
||||
|
||||
it('will make one from a normal animation', function() {
|
||||
// poor mans spy function
|
||||
var value = 0;
|
||||
var anim = new Animation({
|
||||
closure: function() { value++; }
|
||||
});
|
||||
|
||||
var animPromise = PromiseAnimation.fromAnimation(anim);
|
||||
animPromise
|
||||
.then(function() {
|
||||
value++;
|
||||
}).then(function() {
|
||||
// TODO fix
|
||||
expect(value).toBe(2);
|
||||
if (value !== 2) {
|
||||
console.log('a test failed!!');
|
||||
} else {
|
||||
console.log('another test passed');
|
||||
}
|
||||
});
|
||||
|
||||
animPromise.play();
|
||||
expect(value).toBe(1);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue