Skip to content

Commit

Permalink
Switched out nodemon to watch and run test. Implemented parents from …
Browse files Browse the repository at this point in the history
…issue #1
  • Loading branch information
mikkoh committed Mar 21, 2016
1 parent 35c8831 commit da0dac6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 21 deletions.
11 changes: 2 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,13 @@
"after-effects": "^0.3.2",
"babel-cli": "^6.6.5",
"babel-preset-es2015": "^6.6.0",
"npm-watch": "^0.1.1",
"nodemon": "^1.9.1",
"opn-cli": "^3.1.0",
"tape": "^4.5.1"
},
"watch": {
"test-build-run": {
"patterns": ["src", "test"],
"extensions": "js",
"ignore": "test/aeToJSON.js"
}
},
"scripts": {
"start": "npm run watch",
"watch": "npm run open-ae; npm-watch",
"watch": "npm run open-ae; nodemon -w src/ -w test/ -i test/aeToJSON.js -x npm -- run test-build-run",
"test": "npm run open-ae; npm run test-build-run;",
"test-build-run": "npm run build-test; babel-node test/",
"open-ae": "opn test/ae/testProject.aepx",
Expand Down
4 changes: 2 additions & 2 deletions src/getComposition.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ module.exports = function getComposition(comp) {
var layers = collectionToArray(comp.layers);

// now loop through all layers to get keyframes
layers.forEach(function(layer, layers) {
layers.forEach(function(layer) {

// save out the layer
outLayers.push(
getLayer(layer)
getLayer(layer, layers)
);
});

Expand Down
8 changes: 3 additions & 5 deletions src/getLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ module.exports = function getLayer(layer, parentLayers) {

var parent = layer.parent;

// if(parent) {
// parent = parentLayers.indexOf(parent);
// }

// console.log('parent', parent);
if(parent) {
parent = parentLayers.indexOf(parent);
}

return {
name: layer.name,
Expand Down
25 changes: 20 additions & 5 deletions test/layers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
var EXPECTED_NAMES = {
"Test-Comp-Static": [ 'jam3Logo.png', 'iAmANull' ],
"Test-Comp-Static": [ 'static-logo', 'iAmANull' ],
"Test-Comp-Blank": [],
"Test-Comp-Animated": [ 'animatedLogo 2', 'animatedLogo', 'animatedLogoBezier', 'staticLogo' ]
};

var TESTS_FOR_LAYER = {
"iAmANull": function(t, comp, layer) {
// check if null layer is true
t.equal(layer.isNullLayer, true, 'isNullLayer' + comp.name + ' layer ' + layer.name);
},

"static-logo": function(t, comp, layer) {
t.equal(layer.parent, 1, 'static-logo\'s parent is set correctly');
}
};

module.exports = function(t) {
var json = global.jsonFromAE;
var compositions = json.compositions;
Expand All @@ -28,11 +39,15 @@ module.exports = function(t) {
t.ok(layer.properties, 'composition ' + comp.name + ' layer ' + layer.name + ' has properties');
t.ok(layer.isNullLayer !== undefined, 'composition ' + comp.name + ' layer ' + layer.name + ' has isNullLayer');

// want to check that isNullLayer is being exported properly
if(layer.name === 'iAmANull') {
t.ok(layer.isNullLayer === true, 'isNullLayer' + comp.name + ' layer ' + layer.name);
// run tests for specific layers
if(TESTS_FOR_LAYER[ layer.name ]) {
TESTS_FOR_LAYER[ layer.name ](t, comp, layer);

// run test for every other layer
} else {
t.ok(layer.isNullLayer === false, 'isNullLayer value was correct for ' + comp.name + ' layer ' + layer.name);

t.equal(layer.isNullLayer, false, 'isNullLayer value was correct for ' + comp.name + ' layer ' + layer.name);
t.equal(layer.parent, null, 'parent was set to null for ' + comp.name + ' layer ' + layer.name);
}

names.push(layer.name);
Expand Down

0 comments on commit da0dac6

Please sign in to comment.