Skip to content

Commit

Permalink
Add Layer.image type check
Browse files Browse the repository at this point in the history
  • Loading branch information
koenbok committed Nov 2, 2014
1 parent d147a23 commit af57e3d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
3 changes: 3 additions & 0 deletions framer/Layer.coffee
Expand Up @@ -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
Expand Down
22 changes: 16 additions & 6 deletions test/tests/LayerTest.coffee
Expand Up @@ -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"
Expand Down

0 comments on commit af57e3d

Please sign in to comment.