Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Add Layer.image type check
- Loading branch information
Showing
with
19 additions
and
6 deletions.
-
+3
−0
framer/Layer.coffee
-
+16
−6
test/tests/LayerTest.coffee
|
@@ -479,6 +479,9 @@ class exports.Layer extends BaseClass |
|
|
@_getPropertyValue "image" |
|
|
set: (value) -> |
|
|
|
|
|
if not (_.isString(value) or value is null) |
|
|
layerValueTypeError("image", value) |
|
|
|
|
|
currentValue = @_getPropertyValue "image" |
|
|
|
|
|
if currentValue == value |
|
|
|
@@ -129,15 +129,25 @@ describe "Layer", -> |
|
|
layer.properties.image.should.equal imagePath |
|
|
|
|
|
it "should set image", -> |
|
|
|
|
|
imagePath = "static/test.png" |
|
|
layer = new Layer image:imagePath |
|
|
layer.image.should.equal imagePath |
|
|
|
|
|
layer = new Layer y:0, \ |
|
|
x:0, y:0, |
|
|
width:100, height:100, |
|
|
image:imagePath |
|
|
it "should unset image with null", -> |
|
|
layer = new Layer image:"static/test.png" |
|
|
layer.image = null |
|
|
layer.image.should.equal "" |
|
|
|
|
|
layer.image.should.equal imagePath |
|
|
it "should unset image with empty string", -> |
|
|
layer = new Layer image:"static/test.png" |
|
|
layer.image = "" |
|
|
layer.image.should.equal "" |
|
|
|
|
|
it "should test image property type", -> |
|
|
f = -> |
|
|
layer = new Layer |
|
|
layer.image = {} |
|
|
f.should.throw() |
|
|
|
|
|
it "should set name on create", -> |
|
|
layer = new Layer name:"Test" |
|
|