diff --git a/examples/single.html b/examples/single.html index 32b8266..cca64f7 100644 --- a/examples/single.html +++ b/examples/single.html @@ -57,7 +57,7 @@ pattern.draw('cross-dash', '#2ca02c', undefined, patternSize), pattern.draw('dot-dash', '#bcbd22', undefined, patternSize), pattern.draw('dot', '#d62728', undefined, patternSize), - pattern.draw('disc', '#17becf', undefined, patternSize), + pattern.draw('circle', '#17becf', undefined, patternSize), pattern.draw('ring', '#9467bd', undefined, patternSize), pattern.draw('line', '#7f7f7f', undefined, patternSize), pattern.draw('line-vertical', '#8c564b', undefined, patternSize), diff --git a/src/shapes/index.js b/src/shapes/index.js index a6b10d4..e35b122 100644 --- a/src/shapes/index.js +++ b/src/shapes/index.js @@ -1,14 +1,9 @@ import { shapes, deprecatedShapes } from './shapes-list'; -export function getRandomShape(excludedShapeTypes = []) { - const deprecatedShapesList = Object.keys(deprecatedShapes); - let shapesList = Object.keys(shapes); +const completeShapesList = []; - shapesList = shapesList.filter((shape) => { - if (deprecatedShapesList.indexOf(shape) === -1) { - return shape; - } - }); +export function getRandomShape(excludedShapeTypes = []) { + const shapesList = Object.keys(shapes); excludedShapeTypes.forEach(shapeType => { shapesList.splice(shapesList.indexOf(shapeType), 1); @@ -19,4 +14,6 @@ export function getRandomShape(excludedShapeTypes = []) { return shapesList[randomIndex]; } -export default shapes; +Object.assign(completeShapesList, shapes, deprecatedShapes); + +export default completeShapesList; diff --git a/test/patterns.js b/test/patterns.js index bd75582..b8d7cba 100644 --- a/test/patterns.js +++ b/test/patterns.js @@ -31,7 +31,7 @@ function generateColors (total) { describe('pattern', () => { describe('#draw', () => { - it('should return a canvas element', () => { + it('should return a canvas pattern', () => { const testPattern = pattern.draw(); expect(testPattern.toString()).to.equal('[object CanvasPattern]'); diff --git a/test/shapes/index.js b/test/shapes/index.js index 7c236b1..3a44fdc 100644 --- a/test/shapes/index.js +++ b/test/shapes/index.js @@ -8,12 +8,10 @@ global.document = jsdom.jsdom(''); describe('shapes', () => { describe('#getRandomShape', () => { it('should NOT generate the specified excluded shape types', () => { - let containsExcludedShape = false; const randomShapes = []; const excludedShapes = Object.keys(shapes); - const removedShape = excludedShapes[0]; - - excludedShapes.splice(0, 1); + const removedShape = excludedShapes.splice(0, 1)[0]; + let containsExcludedShape = false; for (let i = 0; i < 30; i++) { randomShapes.push(getRandomShape(excludedShapes)); @@ -25,11 +23,11 @@ describe('shapes', () => { }); it('should NOT return a list that includes any deprecated patterns', () => { - let containsDeprecatedShapes = false; const deprecatedShapesList = Object.keys(deprecatedShapes); const randomShapes = []; + let containsDeprecatedShapes = false; - for (let i = 0; i < 100; i++) { + for (let i = 0; i < 30; i++) { randomShapes.push(getRandomShape()); }