From 29254e24899692cb402c00204d94247ee909dc6f Mon Sep 17 00:00:00 2001 From: Solinca Date: Sun, 5 Aug 2018 13:53:15 +0200 Subject: [PATCH 01/18] Update dependencies to use jeff cli with node 6 --- .gitignore | 1 + package.json | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index f6e6869..178f5eb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ test test-output npm-debug.log node_modules +.idea \ No newline at end of file diff --git a/package.json b/package.json index 652ac4f..7976abb 100644 --- a/package.json +++ b/package.json @@ -12,15 +12,15 @@ }, "main": "./src/index.js", "dependencies": { - "async": "0.2.10", - "buffer-crc32": "^0.2.5", - "canvas": "1.1.6", - "commander": "2.2.0", - "fs-extra": "0.8.1", - "glob": "4.3.1", - "image-optim": "0.3.0", - "js-beautify": "1.4.2", - "node-pngquant-native": "0.0.12" + "async": "0.2.10", + "buffer-crc32": "^0.2.5", + "canvas": "1.6.11", + "commander": "2.2.0", + "fs-extra": "0.8.1", + "glob": "4.3.1", + "image-optim": "0.3.0", + "js-beautify": "1.4.2", + "node-pngquant-native": "1.0.5" }, "repository": { "type": "git", @@ -32,4 +32,4 @@ "url": "https://github.com/Wizcorp/jeff/blob/master/LICENSE" } ] -} \ No newline at end of file +} From ede67ec00e65a69c38c8afb18cfabca40eda0656 Mon Sep 17 00:00:00 2001 From: Solinca Date: Sun, 5 Aug 2018 15:11:46 +0200 Subject: [PATCH 02/18] Setting up unit tests --- package.json | 8 +++++++- unit-test-setup.test.js | 10 ++++++++++ unit-tests/first.test.js | 7 +++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 unit-test-setup.test.js create mode 100644 unit-tests/first.test.js diff --git a/package.json b/package.json index 7976abb..6002e29 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,9 @@ "bin": { "jeff": "./bin/jeff" }, + "scripts": { + "test": "NODE_ENV=test mocha './**/*.test.js'" + }, "main": "./src/index.js", "dependencies": { "async": "0.2.10", @@ -20,7 +23,10 @@ "glob": "4.3.1", "image-optim": "0.3.0", "js-beautify": "1.4.2", - "node-pngquant-native": "1.0.5" + "node-pngquant-native": "1.0.5", + "chai": "4.1.2", + "mocha": "5.2.0", + "sinon": "6.1.4" }, "repository": { "type": "git", diff --git a/unit-test-setup.test.js b/unit-test-setup.test.js new file mode 100644 index 0000000..05643ac --- /dev/null +++ b/unit-test-setup.test.js @@ -0,0 +1,10 @@ +const sinon = require('sinon'); +const chai = require('chai'); + +beforeEach(function () { + this.sandbox = sinon.createSandbox(); +}); + +afterEach(function () { + this.sandbox.restore(); +}); \ No newline at end of file diff --git a/unit-tests/first.test.js b/unit-tests/first.test.js new file mode 100644 index 0000000..911ad4d --- /dev/null +++ b/unit-tests/first.test.js @@ -0,0 +1,7 @@ +const expect = require('chai').expect; + +describe('My first test', function () { + it('testing expect', function() { + expect(true).to.eql(true); + }); +}); \ No newline at end of file From 9fb0b959da59f89499bc272f9d60dc468bb61bdc Mon Sep 17 00:00:00 2001 From: Solinca Date: Sun, 5 Aug 2018 16:25:23 +0200 Subject: [PATCH 03/18] Cover SwfObjectProcessor addClassNames method --- unit-tests/SwfObjectProcessor.test.js | 48 +++++++++++++++++++++++++++ unit-tests/first.test.js | 7 ---- 2 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 unit-tests/SwfObjectProcessor.test.js delete mode 100644 unit-tests/first.test.js diff --git a/unit-tests/SwfObjectProcessor.test.js b/unit-tests/SwfObjectProcessor.test.js new file mode 100644 index 0000000..eb7093b --- /dev/null +++ b/unit-tests/SwfObjectProcessor.test.js @@ -0,0 +1,48 @@ +const expect = require('chai').expect; + +const addClassNames = require('../src/SwfObjectProcessor/addClassNames'); + +describe('Add class names', function () { + it('add one class name', function () { + const symbols = [{}]; + + const classNames = { + test: [0] + }; + + const classNamesKeys = Object.keys(classNames); + + const result = addClassNames(symbols, classNames); + + expect(result[0]).to.exist; + expect(result[0]).to.have.own.property('className'); + expect(result[0].className).to.eql(classNamesKeys[0]); + }); + + it('add two or more class name', function () { + const min = 2; + const max = 5; + const random = Math.floor(Math.random() * (max - min + 1)) + min; + + const symbols = []; + + const classNames = { + test: [] + }; + + for(let i = 0; i < random; i++) { + symbols.push({}); + classNames.test.push(i); + } + + const classNamesKeys = Object.keys(classNames); + + const result = addClassNames(symbols, classNames); + + for(let i = 0; i < random; i++) { + expect(result[i]).to.exist; + expect(result[i]).to.have.own.property('className'); + expect(result[i].className).to.eql(classNamesKeys[0]); + } + }); +}); \ No newline at end of file diff --git a/unit-tests/first.test.js b/unit-tests/first.test.js deleted file mode 100644 index 911ad4d..0000000 --- a/unit-tests/first.test.js +++ /dev/null @@ -1,7 +0,0 @@ -const expect = require('chai').expect; - -describe('My first test', function () { - it('testing expect', function() { - expect(true).to.eql(true); - }); -}); \ No newline at end of file From 0c2dd579a1596556870e449d81a9ae5080593c33 Mon Sep 17 00:00:00 2001 From: Solinca Date: Sun, 5 Aug 2018 20:52:37 +0200 Subject: [PATCH 04/18] Cover SwfObjectProcessor createSymbols method --- unit-tests/SwfObjectProcessor.test.js | 249 +++++++++++++++++++++++++- 1 file changed, 246 insertions(+), 3 deletions(-) diff --git a/unit-tests/SwfObjectProcessor.test.js b/unit-tests/SwfObjectProcessor.test.js index eb7093b..b5666cc 100644 --- a/unit-tests/SwfObjectProcessor.test.js +++ b/unit-tests/SwfObjectProcessor.test.js @@ -1,6 +1,7 @@ const expect = require('chai').expect; const addClassNames = require('../src/SwfObjectProcessor/addClassNames'); +const createSymbols = require('../src/SwfObjectProcessor/createSymbols'); describe('Add class names', function () { it('add one class name', function () { @@ -30,7 +31,7 @@ describe('Add class names', function () { test: [] }; - for(let i = 0; i < random; i++) { + for (let i = 0; i < random; i++) { symbols.push({}); classNames.test.push(i); } @@ -39,10 +40,252 @@ describe('Add class names', function () { const result = addClassNames(symbols, classNames); - for(let i = 0; i < random; i++) { + for (let i = 0; i < random; i++) { expect(result[i]).to.exist; expect(result[i]).to.have.own.property('className'); expect(result[i].className).to.eql(classNamesKeys[0]); } }); -}); \ No newline at end of file +}); + +describe('Create Symbols', function () { + it('create symbol from swf object of type \'main\'', function () { + const id = 0; + const frameCount = 1; + + const swfObjects = [{ + id: id, + type: 'main', + frameCount: frameCount + }]; + + const result = createSymbols(swfObjects); + + expect(result[id]).to.exist; + expect(result[id]).to.have.own.property('isAnimation'); + expect(result[id].isAnimation).to.be.true; + expect(result[id]).to.have.own.property('duration'); + expect(result[id].duration).to.eql(frameCount); + }); + + it('create symbol from swf object of type \'image\'', function () { + const id = 0; + const width = 120; + const height = 120; + + const swfObjects = [{ + id: id, + type: 'image', + width: width, + height: height + }]; + + const result = createSymbols(swfObjects); + + expect(result[id]).to.exist; + expect(result[id]).to.have.own.property('isGraphic'); + expect(result[id].isGraphic).to.be.true; + expect(result[id]).to.have.own.property('isImage'); + expect(result[id].isImage).to.be.true; + expect(result[id]).to.have.own.property('maxDims'); + expect(result[id].maxDims).to.eql({}); + expect(result[id]).to.have.own.property('bounds'); + expect(result[id].bounds).to.eql([{ + left: 0, + right: width, + top: 0, + bottom: height + }]); + }); + + it('create symbol from swf object of type \'shape\'', function () { + const id = 0; + const imageID = 0; + const length = 20; + + const swfObjects = [{ + id: id, + type: 'shape', + edges: [ + { + leftFill: { + type: 'pattern', + image: { + id: imageID + }, + matrix: { + scaleX: length, + scaleY: length, + skewX: length, + skewY: length, + moveX: length, + moveY: length + } + }, + records: [] + }, + { + rightFill: { + type: 'pattern', + image: { + id: imageID + }, + matrix: { + scaleX: length, + scaleY: length, + skewX: length, + skewY: length, + moveX: length, + moveY: length + } + }, + records: [] + }, + { + leftFill: { + type: 'non-pattern' + }, + records: [] + }, + { + leftFill: {}, + records: [] + }, + { + rightFill: { + type: 'non-pattern' + }, + records: [] + }, + { + rightFill: {}, + records: [] + } + ], + bounds: { + left: length, + right: length, + top: length, + bottom: length + } + }]; + + const result = createSymbols(swfObjects); + + expect(result[id]).to.exist; + expect(result[id]).to.have.own.property('isGraphic'); + expect(result[id].isGraphic).to.be.true; + expect(result[id]).to.have.own.property('isShape'); + expect(result[id].isShape).to.be.true; + expect(result[id]).to.have.own.property('maxDims'); + expect(result[id].maxDims).to.eql({}); + expect(result[id]).to.have.own.property('bounds'); + expect(result[id].bounds).to.eql([{ + left: length / 20, + right: length / 20, + top: length / 20, + bottom: length / 20 + }]); + expect(result[id]).to.have.own.property('images'); + expect(result[id].images).to.eql([{ + id: imageID, + matrix: [ + length / 20, + length / 20, + length / 20, + length / 20, + length / 20, + length / 20 + ], + image: { + id: imageID + } + }, { + id: imageID, + matrix: [ + length / 20, + length / 20, + length / 20, + length / 20, + length / 20, + length / 20 + ], + image: { + id: imageID + } + }]); + }); + + it('create symbol from swf object of type \'morph\'', function () { + const id = 0; + const startLength = 20; + const endLength = 40; + + const swfObjects = [{ + id: id, + type: 'morph', + startBounds: { + left: startLength, + right: startLength, + top: startLength, + bottom: startLength + }, + endBounds: { + left: endLength, + right: endLength, + top: endLength, + bottom: endLength + } + }]; + + const result = createSymbols(swfObjects); + + expect(result[id]).to.exist; + expect(result[id]).to.have.own.property('isGraphic'); + expect(result[id].isGraphic).to.be.true; + expect(result[id]).to.have.own.property('isMorphing'); + expect(result[id].isMorphing).to.be.true; + expect(result[id]).to.have.own.property('maxDims'); + expect(result[id].maxDims).to.eql({}); + expect(result[id]).to.have.own.property('bounds'); + expect(result[id].bounds).to.eql([{ + left: Math.min(startLength, endLength) / 20, + right: Math.max(startLength, endLength) / 20, + top: Math.min(startLength, endLength) / 20, + bottom: Math.max(startLength, endLength) / 20 + }]); + }); + + it('create symbol from swf object of type \'sprite\'', function () { + const id = 0; + const frameCount = 1; + const length = 20; + + const swfObjects = [{ + id: id, + type: 'sprite', + frameCount: frameCount, + scalingGrid: { + left: length, + right: length, + top: length, + bottom: length + } + }]; + + const result = createSymbols(swfObjects); + + expect(result[id]).to.exist; + expect(result[id]).to.have.own.property('isAnimation'); + expect(result[id].isAnimation).to.be.true; + expect(result[id]).to.have.own.property('duration'); + expect(result[id].duration).to.eql(frameCount); + expect(result[id]).to.have.own.property('scalingGrid'); + expect(result[id].scalingGrid).to.eql({ + left: length / 20, + right: length / 20, + top: length / 20, + bottom: length / 20 + }); + }); +}); From 801e0625c51437e5a82c350cf233725a00e1c1ff Mon Sep 17 00:00:00 2001 From: Solinca Date: Sun, 5 Aug 2018 21:08:46 +0200 Subject: [PATCH 05/18] Little refactor on createSymbols.js ( I made sure it was still working thanks to unit tests ) --- src/SwfObjectProcessor/createSymbols.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/SwfObjectProcessor/createSymbols.js b/src/SwfObjectProcessor/createSymbols.js index 9c3fe63..e905cf3 100644 --- a/src/SwfObjectProcessor/createSymbols.js +++ b/src/SwfObjectProcessor/createSymbols.js @@ -4,7 +4,7 @@ var processShape = require('./processShape'); function createSymbol(swfObject) { var symbol = { id: swfObject.id, swfObject: swfObject, parents: {} }; - + switch(swfObject.type) { case 'main': @@ -28,18 +28,16 @@ function createSymbol(swfObject) { case 'shape': var shapes = swfObject.edges; + var nbShapes = shapes.length; var imagesArray = []; - for (var s = 0; s < shapes.length; s += 1) { + for (var s = 0; s < nbShapes; s++) { var shape = shapes[s]; - var fill = shape.leftFill; - var containsImage = fill ? (fill.type ? (fill.type === 'pattern') : false) : false; - if (!containsImage) { - fill = shape.rightFill; - containsImage = fill ? (fill.type ? (fill.type === 'pattern') : false) : false; - } + var isLeftFill = shape && shape.leftFill && shape.leftFill.type === 'pattern'; + var isRightFill = shape && shape.rightFill && shape.rightFill.type === 'pattern'; - if (containsImage) { + if (isLeftFill || isRightFill) { + var fill = isLeftFill ? shape.leftFill : shape.rightFill; var m = fill.matrix; // In case of an image all the components of the matrix have to be divided by 20 @@ -115,7 +113,7 @@ function createSymbol(swfObject) { function createSymbols(swfObjects) { var symbols = []; var nbSymbols = swfObjects.length; - for (var s = 0; s < nbSymbols; s += 1) { + for (var s = 0; s < nbSymbols; s++) { var swfObject = swfObjects[s]; symbols[swfObject.id] = createSymbol(swfObject); } From aaec7f6d1ba34a434c0ca756df90baeb70b75899 Mon Sep 17 00:00:00 2001 From: Solinca Date: Sun, 5 Aug 2018 21:13:31 +0200 Subject: [PATCH 06/18] Remove sinon cause I don't need sandboxes ( no XHR call in unit test ) --- package.json | 3 +-- unit-test-setup.test.js | 10 ---------- 2 files changed, 1 insertion(+), 12 deletions(-) delete mode 100644 unit-test-setup.test.js diff --git a/package.json b/package.json index 6002e29..d2efb96 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,7 @@ "js-beautify": "1.4.2", "node-pngquant-native": "1.0.5", "chai": "4.1.2", - "mocha": "5.2.0", - "sinon": "6.1.4" + "mocha": "5.2.0" }, "repository": { "type": "git", diff --git a/unit-test-setup.test.js b/unit-test-setup.test.js deleted file mode 100644 index 05643ac..0000000 --- a/unit-test-setup.test.js +++ /dev/null @@ -1,10 +0,0 @@ -const sinon = require('sinon'); -const chai = require('chai'); - -beforeEach(function () { - this.sandbox = sinon.createSandbox(); -}); - -afterEach(function () { - this.sandbox.restore(); -}); \ No newline at end of file From a1ed47d5af538b08a658fe7ea4641448e3db0740 Mon Sep 17 00:00:00 2001 From: Solinca Date: Sun, 5 Aug 2018 22:13:00 +0200 Subject: [PATCH 07/18] Pass unit tests to devDependencies and add Istanbul for code coverage --- .gitignore | 1 + package.json | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 178f5eb..1c6f036 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ test test-output npm-debug.log node_modules +coverage .idea \ No newline at end of file diff --git a/package.json b/package.json index d2efb96..6facdb4 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "jeff": "./bin/jeff" }, "scripts": { - "test": "NODE_ENV=test mocha './**/*.test.js'" + "test": "NODE_ENV=test mocha './**/*.test.js'", + "istanbul": "istanbul cover _mocha $(find ./ -name \"*.test.js\" -not -path \"./node_modules/*\")" }, "main": "./src/index.js", "dependencies": { @@ -23,9 +24,12 @@ "glob": "4.3.1", "image-optim": "0.3.0", "js-beautify": "1.4.2", - "node-pngquant-native": "1.0.5", + "node-pngquant-native": "1.0.5" + }, + "devDependencies" : { "chai": "4.1.2", - "mocha": "5.2.0" + "mocha": "5.2.0", + "istanbul": "0.4.5" }, "repository": { "type": "git", From 1be879387061deac0d5ef3194b6dc3e11f80ffc4 Mon Sep 17 00:00:00 2001 From: Solinca Date: Sun, 5 Aug 2018 22:20:20 +0200 Subject: [PATCH 08/18] More coverage thanks to Istanbul --- unit-tests/SwfObjectProcessor.test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/unit-tests/SwfObjectProcessor.test.js b/unit-tests/SwfObjectProcessor.test.js index b5666cc..560a32a 100644 --- a/unit-tests/SwfObjectProcessor.test.js +++ b/unit-tests/SwfObjectProcessor.test.js @@ -20,6 +20,19 @@ describe('Add class names', function () { expect(result[0].className).to.eql(classNamesKeys[0]); }); + it('add no class', function () { + const symbols = []; + + const classNames = { + test: [0] + }; + + const result = addClassNames(symbols, classNames); + + expect(result).to.be.empty; + }); + + // Monkey test it('add two or more class name', function () { const min = 2; const max = 5; From 5a1ff14d2d6acd6277db25fa2f259fc561d1ee8b Mon Sep 17 00:00:00 2001 From: Solinca Date: Tue, 7 Aug 2018 02:06:46 +0200 Subject: [PATCH 09/18] 100% coverage on SwfObjectProcessor/createSymbols.js --- unit-tests/SwfObjectProcessor.test.js | 101 ++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/unit-tests/SwfObjectProcessor.test.js b/unit-tests/SwfObjectProcessor.test.js index 560a32a..fe08f6a 100644 --- a/unit-tests/SwfObjectProcessor.test.js +++ b/unit-tests/SwfObjectProcessor.test.js @@ -229,6 +229,34 @@ describe('Create Symbols', function () { }]); }); + it('create symbol from swf object of type \'shape\' with no edges', function () { + const id = 0; + const length = 20; + + const swfObjects = [{ + id: id, + type: 'shape', + edges: [], + bounds: { + left: length, + right: length, + top: length, + bottom: length + } + }]; + + const result = createSymbols(swfObjects); + + expect(result[id]).to.exist; + expect(result[id]).to.have.own.property('bounds'); + expect(result[id].bounds).to.eql([{ + left: length / 20, + right: length / 20, + top: length / 20, + bottom: length / 20 + }]); + }); + it('create symbol from swf object of type \'morph\'', function () { const id = 0; const startLength = 20; @@ -301,4 +329,77 @@ describe('Create Symbols', function () { bottom: length / 20 }); }); + + it('create symbol from swf object of type \'sprite\' with no scalingGrid', function () { + const id = 0; + const frameCount = 1; + + const swfObjects = [{ + id: id, + type: 'sprite', + frameCount: frameCount + }]; + + const result = createSymbols(swfObjects); + + expect(result[id]).to.exist; + expect(result[id]).to.have.own.property('isAnimation'); + expect(result[id].isAnimation).to.be.true; + expect(result[id]).to.have.own.property('duration'); + expect(result[id].duration).to.eql(frameCount); + }); + + it('create symbol from swf object of type \'font\'', function () { + const id = 0; + + const swfObjects = [{ + id: id, + type: 'font' + }]; + + const result = createSymbols(swfObjects); + + expect(result[id]).to.exist; + expect(result[id]).to.eql({ + id: id, + swfObject: swfObjects[0], + parents: {} + }); + }); + + it('create symbol from swf object of type \'text\'', function () { + const id = 0; + + const swfObjects = [{ + id: id, + type: 'text' + }]; + + const result = createSymbols(swfObjects); + + expect(result[id]).to.exist; + expect(result[id]).to.eql({ + id: id, + swfObject: swfObjects[0], + parents: {} + }); + }); + + it('create symbol from swf object of unknown type', function () { + const id = 0; + + const swfObjects = [{ + id: id, + type: 'null' + }]; + + const result = createSymbols(swfObjects); + + expect(result[id]).to.exist; + expect(result[id]).to.eql({ + id: id, + swfObject: swfObjects[0], + parents: {} + }); + }); }); From 7cdf64d6dcc8adbf9f68790589d17ca96652021b Mon Sep 17 00:00:00 2001 From: Solinca Date: Tue, 7 Aug 2018 02:58:49 +0200 Subject: [PATCH 10/18] Cover SwfObjectProcessor removeSymbols method --- unit-tests/SwfObjectProcessor.test.js | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/unit-tests/SwfObjectProcessor.test.js b/unit-tests/SwfObjectProcessor.test.js index fe08f6a..8565947 100644 --- a/unit-tests/SwfObjectProcessor.test.js +++ b/unit-tests/SwfObjectProcessor.test.js @@ -2,6 +2,7 @@ const expect = require('chai').expect; const addClassNames = require('../src/SwfObjectProcessor/addClassNames'); const createSymbols = require('../src/SwfObjectProcessor/createSymbols'); +const removeSymbols = require('../src/SwfObjectProcessor/removeSymbols'); describe('Add class names', function () { it('add one class name', function () { @@ -403,3 +404,41 @@ describe('Create Symbols', function () { }); }); }); + +describe('Remove Symbols', function () { + it('remove 4 symbols: 1 success and 3 fails', function () { + const symbols = [{ + className: 'test' + }, { + empty: '' + }, { + className: 'null' + }]; + + const classSymbols = [{ + children: [{ + id: 0 + }, { + id: 1 + }, { + id: 2 + }] + }, { + empty: '' + }]; + + const removeList = 'test'; + + removeSymbols(symbols, classSymbols, removeList); + + expect(classSymbols).to.be.eql([{ + children: [{ + id: 1 + }, { + id: 2 + }] + }, { + empty: '' + }]); + }) +}); \ No newline at end of file From 9c22898606b4363f1bda5f87043976f3c1fcabea Mon Sep 17 00:00:00 2001 From: Solinca Date: Tue, 7 Aug 2018 03:11:28 +0200 Subject: [PATCH 11/18] Make Remove Symbols tests more granular --- unit-tests/SwfObjectProcessor.test.js | 76 +++++++++++++++++++++------ 1 file changed, 61 insertions(+), 15 deletions(-) diff --git a/unit-tests/SwfObjectProcessor.test.js b/unit-tests/SwfObjectProcessor.test.js index 8565947..8069bde 100644 --- a/unit-tests/SwfObjectProcessor.test.js +++ b/unit-tests/SwfObjectProcessor.test.js @@ -406,39 +406,85 @@ describe('Create Symbols', function () { }); describe('Remove Symbols', function () { - it('remove 4 symbols: 1 success and 3 fails', function () { + it('remove 1 symbol', function () { const symbols = [{ className: 'test' - }, { - empty: '' - }, { - className: 'null' }]; const classSymbols = [{ children: [{ id: 0 - }, { - id: 1 - }, { - id: 2 }] - }, { + }]; + + const removeList = 'test'; + + removeSymbols(symbols, classSymbols, removeList); + + expect(classSymbols).to.be.eql([{ + children: [] + }]); + }); + + it('fail removing symbol because className doesn\'t exist in removeList', function () { + const symbols = [{ + className: 'test' + }]; + + const classSymbols = [{ + children: [{ + id: 0 + }] + }]; + + const removeList = 'null'; + + removeSymbols(symbols, classSymbols, removeList); + + expect(classSymbols).to.be.eql([{ + children: [{ + id: 0 + }] + }]); + }); + + it('fail removing symbol because symbols doesn\'t have className attribute', function () { + const symbols = [{ empty: '' }]; + const classSymbols = [{ + children: [{ + id: 0 + }] + }]; + const removeList = 'test'; removeSymbols(symbols, classSymbols, removeList); expect(classSymbols).to.be.eql([{ children: [{ - id: 1 - }, { - id: 2 + id: 0 }] - }, { + }]); + }); + + it('fail removing symbol because classSymbols doesn\'t have children attribute', function () { + const symbols = [{ + className: 'test' + }]; + + const classSymbols = [{ + empty: '' + }]; + + const removeList = 'test'; + + removeSymbols(symbols, classSymbols, removeList); + + expect(classSymbols).to.be.eql([{ empty: '' }]); - }) + }); }); \ No newline at end of file From e9c5b93b1f2e2279fb06d053ca1ec722d61b8362 Mon Sep 17 00:00:00 2001 From: Solinca Date: Tue, 7 Aug 2018 03:47:19 +0200 Subject: [PATCH 12/18] Declare some const for every sub test on Remove Symbols --- unit-tests/SwfObjectProcessor.test.js | 38 +++++++++------------------ 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/unit-tests/SwfObjectProcessor.test.js b/unit-tests/SwfObjectProcessor.test.js index 8069bde..590e509 100644 --- a/unit-tests/SwfObjectProcessor.test.js +++ b/unit-tests/SwfObjectProcessor.test.js @@ -406,19 +406,19 @@ describe('Create Symbols', function () { }); describe('Remove Symbols', function () { - it('remove 1 symbol', function () { - const symbols = [{ - className: 'test' - }]; + const symbols = [{ + className: 'test' + }]; + const removeList = 'test'; + + it('remove 1 symbol', function () { const classSymbols = [{ children: [{ id: 0 }] }]; - const removeList = 'test'; - removeSymbols(symbols, classSymbols, removeList); expect(classSymbols).to.be.eql([{ @@ -427,19 +427,15 @@ describe('Remove Symbols', function () { }); it('fail removing symbol because className doesn\'t exist in removeList', function () { - const symbols = [{ - className: 'test' - }]; - const classSymbols = [{ children: [{ id: 0 }] }]; - const removeList = 'null'; + const emptyRemoveList = 'null'; - removeSymbols(symbols, classSymbols, removeList); + removeSymbols(symbols, classSymbols, emptyRemoveList); expect(classSymbols).to.be.eql([{ children: [{ @@ -449,7 +445,7 @@ describe('Remove Symbols', function () { }); it('fail removing symbol because symbols doesn\'t have className attribute', function () { - const symbols = [{ + const emptySymbols = [{ empty: '' }]; @@ -459,9 +455,7 @@ describe('Remove Symbols', function () { }] }]; - const removeList = 'test'; - - removeSymbols(symbols, classSymbols, removeList); + removeSymbols(emptySymbols, classSymbols, removeList); expect(classSymbols).to.be.eql([{ children: [{ @@ -471,19 +465,13 @@ describe('Remove Symbols', function () { }); it('fail removing symbol because classSymbols doesn\'t have children attribute', function () { - const symbols = [{ - className: 'test' - }]; - - const classSymbols = [{ + const emptyClassSymbols = [{ empty: '' }]; - const removeList = 'test'; - - removeSymbols(symbols, classSymbols, removeList); + removeSymbols(symbols, emptyClassSymbols, removeList); - expect(classSymbols).to.be.eql([{ + expect(emptyClassSymbols).to.be.eql([{ empty: '' }]); }); From 5d4080eb0bb2aa559cf3d201f0b5db2c172dbd6c Mon Sep 17 00:00:00 2001 From: Solinca Date: Tue, 7 Aug 2018 04:10:54 +0200 Subject: [PATCH 13/18] Add some toughness on removeSymbols.js --- src/SwfObjectProcessor/removeSymbols.js | 60 ++++++++++++++----------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/src/SwfObjectProcessor/removeSymbols.js b/src/SwfObjectProcessor/removeSymbols.js index 4ec5885..b5055ad 100644 --- a/src/SwfObjectProcessor/removeSymbols.js +++ b/src/SwfObjectProcessor/removeSymbols.js @@ -1,30 +1,40 @@ 'use strict'; -function removeSymbols(symbols, classSymbols, removeList){ - var nbClassSymbols = classSymbols.length; - for (var s = 0; s < nbClassSymbols; s += 1) { - - var classSymbol = classSymbols[s]; - if (!classSymbol || !classSymbol.children) { - continue; - } - - var children = classSymbol.children; - for (var c = 0; c < children.length; c += 1) { - - var child = children[c]; - var symbol = symbols[child.id]; - if (!symbol.className){ - continue; - } - - var idx = removeList.indexOf(symbol.className); - if (idx !== -1) { - children.splice(c, 1); - c -= 1; - } - } - } +function removeSymbols(symbols, classSymbols, removeList) { + var nbClassSymbols = classSymbols.length; + + for (var s = 0; s < nbClassSymbols; s++) { + var classSymbol = classSymbols[s]; + + if (!classSymbol || !classSymbol.children) { + continue; + } + + var children = classSymbol.children; + + for (var c = 0; c < children.length; c++) { + var child = children[c]; + + if (!child || typeof child.id === "undefined") { + continue; + } + + var symbol = symbols[child.id]; + + if (!symbol || !symbol.className) { + continue; + } + + if (removeList && removeList.length > 0) { + var idx = removeList.indexOf(symbol.className); + + if (idx !== -1) { + children.splice(c, 1); + c -= 1; + } + } + } + } } module.exports = removeSymbols; \ No newline at end of file From 9774b6cb0ee9de18ae9f2a57bd11e52495d983c0 Mon Sep 17 00:00:00 2001 From: Solinca Date: Tue, 7 Aug 2018 04:16:54 +0200 Subject: [PATCH 14/18] Add some test for removeSymbols to cover the added toughness --- unit-tests/SwfObjectProcessor.test.js | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/unit-tests/SwfObjectProcessor.test.js b/unit-tests/SwfObjectProcessor.test.js index 590e509..a1511e0 100644 --- a/unit-tests/SwfObjectProcessor.test.js +++ b/unit-tests/SwfObjectProcessor.test.js @@ -444,6 +444,24 @@ describe('Remove Symbols', function () { }]); }); + it('fail removing symbol because removeList is null or empty', function () { + const classSymbols = [{ + children: [{ + id: 0 + }] + }]; + + const emptyRemoveList = null; + + removeSymbols(symbols, classSymbols, emptyRemoveList); + + expect(classSymbols).to.be.eql([{ + children: [{ + id: 0 + }] + }]); + }); + it('fail removing symbol because symbols doesn\'t have className attribute', function () { const emptySymbols = [{ empty: '' @@ -475,4 +493,20 @@ describe('Remove Symbols', function () { empty: '' }]); }); + + it('fail removing symbol because classSymbols\' children doesn\'t have id attribute', function () { + const classSymbols = [{ + children: [{ + empty: '' + }] + }]; + + removeSymbols(symbols, classSymbols, removeList); + + expect(classSymbols).to.be.eql([{ + children: [{ + empty: '' + }] + }]); + }); }); \ No newline at end of file From 27a7cdcec4b1fede18991fd5f57eba4fabc7b164 Mon Sep 17 00:00:00 2001 From: Solinca Date: Wed, 8 Aug 2018 03:01:30 +0200 Subject: [PATCH 15/18] Simplify npm scripts --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6facdb4..16e9189 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "jeff": "./bin/jeff" }, "scripts": { - "test": "NODE_ENV=test mocha './**/*.test.js'", - "istanbul": "istanbul cover _mocha $(find ./ -name \"*.test.js\" -not -path \"./node_modules/*\")" + "test": "NODE_ENV=test mocha --recursive unit-tests", + "istanbul": "istanbul cover _mocha unit-tests/**/*.test.js" }, "main": "./src/index.js", "dependencies": { From 02d1717ff20ed25627a5714bd39baf9dc7407e6e Mon Sep 17 00:00:00 2001 From: Solinca Date: Wed, 8 Aug 2018 03:02:43 +0200 Subject: [PATCH 16/18] Separate all unit tests into 3 files --- .../SwfObjectProcessor/addClassNames.test.js | 61 ++++++ .../createSymbols.test.js} | 188 +----------------- .../SwfObjectProcessor/removeSymbols.test.js | 109 ++++++++++ 3 files changed, 181 insertions(+), 177 deletions(-) create mode 100644 unit-tests/SwfObjectProcessor/addClassNames.test.js rename unit-tests/{SwfObjectProcessor.test.js => SwfObjectProcessor/createSymbols.test.js} (67%) create mode 100644 unit-tests/SwfObjectProcessor/removeSymbols.test.js diff --git a/unit-tests/SwfObjectProcessor/addClassNames.test.js b/unit-tests/SwfObjectProcessor/addClassNames.test.js new file mode 100644 index 0000000..e53cff0 --- /dev/null +++ b/unit-tests/SwfObjectProcessor/addClassNames.test.js @@ -0,0 +1,61 @@ +const expect = require('chai').expect; + +const addClassNamesTest = require('../../src/SwfObjectProcessor/addClassNames'); + +describe('Add class names', function () { + it('add one class name', function () { + const symbols = [{}]; + + const classNames = { + test: [0] + }; + + const classNamesKeys = Object.keys(classNames); + + const result = addClassNamesTest(symbols, classNames); + + expect(result[0]).to.exist; + expect(result[0]).to.have.own.property('className'); + expect(result[0].className).to.eql(classNamesKeys[0]); + }); + + it('add no class', function () { + const symbols = []; + + const classNames = { + test: [0] + }; + + const result = addClassNamesTest(symbols, classNames); + + expect(result).to.be.empty; + }); + + // Monkey test + it('add two or more class name', function () { + const min = 2; + const max = 5; + const random = Math.floor(Math.random() * (max - min + 1)) + min; + + const symbols = []; + + const classNames = { + test: [] + }; + + for (let i = 0; i < random; i++) { + symbols.push({}); + classNames.test.push(i); + } + + const classNamesKeys = Object.keys(classNames); + + const result = addClassNames(symbols, classNames); + + for (let i = 0; i < random; i++) { + expect(result[i]).to.exist; + expect(result[i]).to.have.own.property('className'); + expect(result[i].className).to.eql(classNamesKeys[0]); + } + }); +}); \ No newline at end of file diff --git a/unit-tests/SwfObjectProcessor.test.js b/unit-tests/SwfObjectProcessor/createSymbols.test.js similarity index 67% rename from unit-tests/SwfObjectProcessor.test.js rename to unit-tests/SwfObjectProcessor/createSymbols.test.js index a1511e0..54c3b16 100644 --- a/unit-tests/SwfObjectProcessor.test.js +++ b/unit-tests/SwfObjectProcessor/createSymbols.test.js @@ -1,66 +1,6 @@ const expect = require('chai').expect; -const addClassNames = require('../src/SwfObjectProcessor/addClassNames'); -const createSymbols = require('../src/SwfObjectProcessor/createSymbols'); -const removeSymbols = require('../src/SwfObjectProcessor/removeSymbols'); - -describe('Add class names', function () { - it('add one class name', function () { - const symbols = [{}]; - - const classNames = { - test: [0] - }; - - const classNamesKeys = Object.keys(classNames); - - const result = addClassNames(symbols, classNames); - - expect(result[0]).to.exist; - expect(result[0]).to.have.own.property('className'); - expect(result[0].className).to.eql(classNamesKeys[0]); - }); - - it('add no class', function () { - const symbols = []; - - const classNames = { - test: [0] - }; - - const result = addClassNames(symbols, classNames); - - expect(result).to.be.empty; - }); - - // Monkey test - it('add two or more class name', function () { - const min = 2; - const max = 5; - const random = Math.floor(Math.random() * (max - min + 1)) + min; - - const symbols = []; - - const classNames = { - test: [] - }; - - for (let i = 0; i < random; i++) { - symbols.push({}); - classNames.test.push(i); - } - - const classNamesKeys = Object.keys(classNames); - - const result = addClassNames(symbols, classNames); - - for (let i = 0; i < random; i++) { - expect(result[i]).to.exist; - expect(result[i]).to.have.own.property('className'); - expect(result[i].className).to.eql(classNamesKeys[0]); - } - }); -}); +const createSymbolsTest = require('../../src/SwfObjectProcessor/createSymbols'); describe('Create Symbols', function () { it('create symbol from swf object of type \'main\'', function () { @@ -73,7 +13,7 @@ describe('Create Symbols', function () { frameCount: frameCount }]; - const result = createSymbols(swfObjects); + const result = createSymbolsTest(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.have.own.property('isAnimation'); @@ -94,7 +34,7 @@ describe('Create Symbols', function () { height: height }]; - const result = createSymbols(swfObjects); + const result = createSymbolsTest(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.have.own.property('isGraphic'); @@ -184,7 +124,7 @@ describe('Create Symbols', function () { } }]; - const result = createSymbols(swfObjects); + const result = createSymbolsTest(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.have.own.property('isGraphic'); @@ -246,7 +186,7 @@ describe('Create Symbols', function () { } }]; - const result = createSymbols(swfObjects); + const result = createSymbolsTest(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.have.own.property('bounds'); @@ -280,7 +220,7 @@ describe('Create Symbols', function () { } }]; - const result = createSymbols(swfObjects); + const result = createSymbolsTest(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.have.own.property('isGraphic'); @@ -315,7 +255,7 @@ describe('Create Symbols', function () { } }]; - const result = createSymbols(swfObjects); + const result = createSymbolsTest(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.have.own.property('isAnimation'); @@ -341,7 +281,7 @@ describe('Create Symbols', function () { frameCount: frameCount }]; - const result = createSymbols(swfObjects); + const result = createSymbolsTest(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.have.own.property('isAnimation'); @@ -358,7 +298,7 @@ describe('Create Symbols', function () { type: 'font' }]; - const result = createSymbols(swfObjects); + const result = createSymbolsTest(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.eql({ @@ -376,7 +316,7 @@ describe('Create Symbols', function () { type: 'text' }]; - const result = createSymbols(swfObjects); + const result = createSymbolsTest(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.eql({ @@ -394,7 +334,7 @@ describe('Create Symbols', function () { type: 'null' }]; - const result = createSymbols(swfObjects); + const result = createSymbolsTest(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.eql({ @@ -403,110 +343,4 @@ describe('Create Symbols', function () { parents: {} }); }); -}); - -describe('Remove Symbols', function () { - const symbols = [{ - className: 'test' - }]; - - const removeList = 'test'; - - it('remove 1 symbol', function () { - const classSymbols = [{ - children: [{ - id: 0 - }] - }]; - - removeSymbols(symbols, classSymbols, removeList); - - expect(classSymbols).to.be.eql([{ - children: [] - }]); - }); - - it('fail removing symbol because className doesn\'t exist in removeList', function () { - const classSymbols = [{ - children: [{ - id: 0 - }] - }]; - - const emptyRemoveList = 'null'; - - removeSymbols(symbols, classSymbols, emptyRemoveList); - - expect(classSymbols).to.be.eql([{ - children: [{ - id: 0 - }] - }]); - }); - - it('fail removing symbol because removeList is null or empty', function () { - const classSymbols = [{ - children: [{ - id: 0 - }] - }]; - - const emptyRemoveList = null; - - removeSymbols(symbols, classSymbols, emptyRemoveList); - - expect(classSymbols).to.be.eql([{ - children: [{ - id: 0 - }] - }]); - }); - - it('fail removing symbol because symbols doesn\'t have className attribute', function () { - const emptySymbols = [{ - empty: '' - }]; - - const classSymbols = [{ - children: [{ - id: 0 - }] - }]; - - removeSymbols(emptySymbols, classSymbols, removeList); - - expect(classSymbols).to.be.eql([{ - children: [{ - id: 0 - }] - }]); - }); - - it('fail removing symbol because classSymbols doesn\'t have children attribute', function () { - const emptyClassSymbols = [{ - empty: '' - }]; - - removeSymbols(symbols, emptyClassSymbols, removeList); - - expect(emptyClassSymbols).to.be.eql([{ - empty: '' - }]); - }); - - it('fail removing symbol because classSymbols\' children doesn\'t have id attribute', function () { - const classSymbols = [{ - children: [{ - empty: '' - }] - }]; - - removeSymbols(symbols, classSymbols, removeList); - - expect(classSymbols).to.be.eql([{ - children: [{ - empty: '' - }] - }]); - }); }); \ No newline at end of file diff --git a/unit-tests/SwfObjectProcessor/removeSymbols.test.js b/unit-tests/SwfObjectProcessor/removeSymbols.test.js new file mode 100644 index 0000000..fde81ca --- /dev/null +++ b/unit-tests/SwfObjectProcessor/removeSymbols.test.js @@ -0,0 +1,109 @@ +const expect = require('chai').expect; + +const removeSymbolsTest = require('../../src/SwfObjectProcessor/removeSymbols'); + +describe('Remove Symbols', function () { + const symbols = [{ + className: 'test' + }]; + + const removeList = 'test'; + + it('remove 1 symbol', function () { + const classSymbols = [{ + children: [{ + id: 0 + }] + }]; + + removeSymbolsTest(symbols, classSymbols, removeList); + + expect(classSymbols).to.be.eql([{ + children: [] + }]); + }); + + it('fail removing symbol because className doesn\'t exist in removeList', function () { + const classSymbols = [{ + children: [{ + id: 0 + }] + }]; + + const emptyRemoveList = 'null'; + + removeSymbolsTest(symbols, classSymbols, emptyRemoveList); + + expect(classSymbols).to.be.eql([{ + children: [{ + id: 0 + }] + }]); + }); + + it('fail removing symbol because removeList is null or empty', function () { + const classSymbols = [{ + children: [{ + id: 0 + }] + }]; + + const emptyRemoveList = null; + + removeSymbolsTest(symbols, classSymbols, emptyRemoveList); + + expect(classSymbols).to.be.eql([{ + children: [{ + id: 0 + }] + }]); + }); + + it('fail removing symbol because symbols doesn\'t have className attribute', function () { + const emptySymbols = [{ + empty: '' + }]; + + const classSymbols = [{ + children: [{ + id: 0 + }] + }]; + + removeSymbolsTest(emptySymbols, classSymbols, removeList); + + expect(classSymbols).to.be.eql([{ + children: [{ + id: 0 + }] + }]); + }); + + it('fail removing symbol because classSymbols doesn\'t have children attribute', function () { + const emptyClassSymbols = [{ + empty: '' + }]; + + removeSymbolsTest(symbols, emptyClassSymbols, removeList); + + expect(emptyClassSymbols).to.be.eql([{ + empty: '' + }]); + }); + + it('fail removing symbol because classSymbols\' children doesn\'t have id attribute', function () { + const classSymbols = [{ + children: [{ + empty: '' + }] + }]; + + removeSymbolsTest(symbols, classSymbols, removeList); + + expect(classSymbols).to.be.eql([{ + children: [{ + empty: '' + }] + }]); + }); +}); \ No newline at end of file From a29ce283a3f1311acdb29a731602e0e39325aae7 Mon Sep 17 00:00:00 2001 From: Solinca Date: Wed, 8 Aug 2018 03:03:06 +0200 Subject: [PATCH 17/18] Remove monkey test --- .../SwfObjectProcessor/addClassNames.test.js | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/unit-tests/SwfObjectProcessor/addClassNames.test.js b/unit-tests/SwfObjectProcessor/addClassNames.test.js index e53cff0..54c426e 100644 --- a/unit-tests/SwfObjectProcessor/addClassNames.test.js +++ b/unit-tests/SwfObjectProcessor/addClassNames.test.js @@ -30,32 +30,4 @@ describe('Add class names', function () { expect(result).to.be.empty; }); - - // Monkey test - it('add two or more class name', function () { - const min = 2; - const max = 5; - const random = Math.floor(Math.random() * (max - min + 1)) + min; - - const symbols = []; - - const classNames = { - test: [] - }; - - for (let i = 0; i < random; i++) { - symbols.push({}); - classNames.test.push(i); - } - - const classNamesKeys = Object.keys(classNames); - - const result = addClassNames(symbols, classNames); - - for (let i = 0; i < random; i++) { - expect(result[i]).to.exist; - expect(result[i]).to.have.own.property('className'); - expect(result[i].className).to.eql(classNamesKeys[0]); - } - }); }); \ No newline at end of file From 9dae435c5e177a6ac2e7abc826f597437a2e18e9 Mon Sep 17 00:00:00 2001 From: Solinca Date: Wed, 8 Aug 2018 03:08:38 +0200 Subject: [PATCH 18/18] Clean refactor --- .../SwfObjectProcessor/addClassNames.test.js | 6 ++--- .../SwfObjectProcessor/createSymbols.test.js | 22 +++++++++---------- .../SwfObjectProcessor/removeSymbols.test.js | 14 ++++++------ 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/unit-tests/SwfObjectProcessor/addClassNames.test.js b/unit-tests/SwfObjectProcessor/addClassNames.test.js index 54c426e..14b1842 100644 --- a/unit-tests/SwfObjectProcessor/addClassNames.test.js +++ b/unit-tests/SwfObjectProcessor/addClassNames.test.js @@ -1,6 +1,6 @@ const expect = require('chai').expect; -const addClassNamesTest = require('../../src/SwfObjectProcessor/addClassNames'); +const addClassNames = require('../../src/SwfObjectProcessor/addClassNames'); describe('Add class names', function () { it('add one class name', function () { @@ -12,7 +12,7 @@ describe('Add class names', function () { const classNamesKeys = Object.keys(classNames); - const result = addClassNamesTest(symbols, classNames); + const result = addClassNames(symbols, classNames); expect(result[0]).to.exist; expect(result[0]).to.have.own.property('className'); @@ -26,7 +26,7 @@ describe('Add class names', function () { test: [0] }; - const result = addClassNamesTest(symbols, classNames); + const result = addClassNames(symbols, classNames); expect(result).to.be.empty; }); diff --git a/unit-tests/SwfObjectProcessor/createSymbols.test.js b/unit-tests/SwfObjectProcessor/createSymbols.test.js index 54c3b16..c1ddf5b 100644 --- a/unit-tests/SwfObjectProcessor/createSymbols.test.js +++ b/unit-tests/SwfObjectProcessor/createSymbols.test.js @@ -1,6 +1,6 @@ const expect = require('chai').expect; -const createSymbolsTest = require('../../src/SwfObjectProcessor/createSymbols'); +const createSymbols = require('../../src/SwfObjectProcessor/createSymbols'); describe('Create Symbols', function () { it('create symbol from swf object of type \'main\'', function () { @@ -13,7 +13,7 @@ describe('Create Symbols', function () { frameCount: frameCount }]; - const result = createSymbolsTest(swfObjects); + const result = createSymbols(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.have.own.property('isAnimation'); @@ -34,7 +34,7 @@ describe('Create Symbols', function () { height: height }]; - const result = createSymbolsTest(swfObjects); + const result = createSymbols(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.have.own.property('isGraphic'); @@ -124,7 +124,7 @@ describe('Create Symbols', function () { } }]; - const result = createSymbolsTest(swfObjects); + const result = createSymbols(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.have.own.property('isGraphic'); @@ -186,7 +186,7 @@ describe('Create Symbols', function () { } }]; - const result = createSymbolsTest(swfObjects); + const result = createSymbols(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.have.own.property('bounds'); @@ -220,7 +220,7 @@ describe('Create Symbols', function () { } }]; - const result = createSymbolsTest(swfObjects); + const result = createSymbols(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.have.own.property('isGraphic'); @@ -255,7 +255,7 @@ describe('Create Symbols', function () { } }]; - const result = createSymbolsTest(swfObjects); + const result = createSymbols(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.have.own.property('isAnimation'); @@ -281,7 +281,7 @@ describe('Create Symbols', function () { frameCount: frameCount }]; - const result = createSymbolsTest(swfObjects); + const result = createSymbols(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.have.own.property('isAnimation'); @@ -298,7 +298,7 @@ describe('Create Symbols', function () { type: 'font' }]; - const result = createSymbolsTest(swfObjects); + const result = createSymbols(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.eql({ @@ -316,7 +316,7 @@ describe('Create Symbols', function () { type: 'text' }]; - const result = createSymbolsTest(swfObjects); + const result = createSymbols(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.eql({ @@ -334,7 +334,7 @@ describe('Create Symbols', function () { type: 'null' }]; - const result = createSymbolsTest(swfObjects); + const result = createSymbols(swfObjects); expect(result[id]).to.exist; expect(result[id]).to.eql({ diff --git a/unit-tests/SwfObjectProcessor/removeSymbols.test.js b/unit-tests/SwfObjectProcessor/removeSymbols.test.js index fde81ca..2ee0ee4 100644 --- a/unit-tests/SwfObjectProcessor/removeSymbols.test.js +++ b/unit-tests/SwfObjectProcessor/removeSymbols.test.js @@ -1,6 +1,6 @@ const expect = require('chai').expect; -const removeSymbolsTest = require('../../src/SwfObjectProcessor/removeSymbols'); +const removeSymbols = require('../../src/SwfObjectProcessor/removeSymbols'); describe('Remove Symbols', function () { const symbols = [{ @@ -16,7 +16,7 @@ describe('Remove Symbols', function () { }] }]; - removeSymbolsTest(symbols, classSymbols, removeList); + removeSymbols(symbols, classSymbols, removeList); expect(classSymbols).to.be.eql([{ children: [] @@ -32,7 +32,7 @@ describe('Remove Symbols', function () { const emptyRemoveList = 'null'; - removeSymbolsTest(symbols, classSymbols, emptyRemoveList); + removeSymbols(symbols, classSymbols, emptyRemoveList); expect(classSymbols).to.be.eql([{ children: [{ @@ -50,7 +50,7 @@ describe('Remove Symbols', function () { const emptyRemoveList = null; - removeSymbolsTest(symbols, classSymbols, emptyRemoveList); + removeSymbols(symbols, classSymbols, emptyRemoveList); expect(classSymbols).to.be.eql([{ children: [{ @@ -70,7 +70,7 @@ describe('Remove Symbols', function () { }] }]; - removeSymbolsTest(emptySymbols, classSymbols, removeList); + removeSymbols(emptySymbols, classSymbols, removeList); expect(classSymbols).to.be.eql([{ children: [{ @@ -84,7 +84,7 @@ describe('Remove Symbols', function () { empty: '' }]; - removeSymbolsTest(symbols, emptyClassSymbols, removeList); + removeSymbols(symbols, emptyClassSymbols, removeList); expect(emptyClassSymbols).to.be.eql([{ empty: '' @@ -98,7 +98,7 @@ describe('Remove Symbols', function () { }] }]; - removeSymbolsTest(symbols, classSymbols, removeList); + removeSymbols(symbols, classSymbols, removeList); expect(classSymbols).to.be.eql([{ children: [{