       expected =
         width: 1024
       out.on 'data', (data) ->
-        chai.expect(data).to.be.an 'object'
-        chai.expect(data.width).to.be.equal expected.width
-        chai.expect(data.originalWidth).to.be.equal original.width
-        done()
+        buffer = sharp data
+        buffer.metadata (err, meta) ->
+          chai.expect(meta.width).to.be.equal expected.width
+          done()
+
+      width.send expected.width
+      testutils.getBuffer __dirname + '/fixtures/foo.jpeg', (buffer) ->
+        ins.send buffer
+
+  describe 'when passed a path to JPG file', ->
+    original =
+      width: 2048
+      height: 1536
+    it 'should resize it to the specified dimension', (done) ->
+      expected =
+        width: 1024
+      out.on 'data', (data) ->
+        buffer = sharp data
+        buffer.metadata (err, meta) ->
+          chai.expect(meta.width).to.be.equal expected.width
+          done()
 
       width.send expected.width
       ins.send __dirname + '/fixtures/foo.jpeg'

  chai = require 'chai' unless chai
  Resize = require '../components/Resize-node.coffee'
  testutils = require './testutils'
else
  Resize = require 'noflo-sharp/components/Resize.js'
  testutils = require 'noflo-image/spec/testutils.js'

        width: 128
        height: 256
      out.on 'data', (data) ->
        buffer = sharp data
        buffer.metadata (err, meta) ->
          chai.expect(meta.width).to.be.equal expected.width
          chai.expect(meta.height).to.be.equal expected.height
          done()

      width.send expected.width
      height.send expected.height
      testutils.getBuffer __dirname + '/fixtures/foo.jpeg', (buffer) ->
        ins.send buffer

    it 'should resize it right when given just width', (done) ->
      expected =
        width: 128
      out.on 'data', (data) ->
        buffer = sharp data
        buffer.metadata (err, meta) ->
          chai.expect(meta.width).to.be.equal expected.width
          chai.expect(meta.height).to.be.equal expected.width
          done()

      width.send expected.width
      testutils.getBuffer __dirname + '/fixtures/lenna.png', (buffer) ->
        ins.send buffer

    it 'should resize it right when given just height', (done) ->
      expected =
        height: 128
      out.on 'data', (data) ->
        buffer = sharp data
        buffer.metadata (err, meta) ->
          chai.expect(meta.width).to.be.equal expected.height
          chai.expect(meta.height).to.be.equal expected.height
          done()

      height.send expected.height
      testutils.getBuffer __dirname + '/fixtures/lenna.png', (buffer) ->
        ins.send buffer

    it 'should resize it right to default dimension', (done) ->
      expected =
        width: 256
        height: 256
      out.on 'data', (data) ->
        buffer = sharp data
        buffer.metadata (err, meta) ->
          chai.expect(meta.width).to.be.equal expected.width
          chai.expect(meta.height).to.be.equal expected.height
          done()

      testutils.getBuffer __dirname + '/fixtures/lenna.png', (buffer) ->
        ins.send buffer

    it 'should not resize up (just down, without enlargement)', (done) ->
      expected =
        width: 512
        height: 512
      out.on 'data', (data) ->
        buffer = sharp data
        buffer.metadata (err, meta) ->
          chai.expect(meta.width).to.be.equal expected.width
          chai.expect(meta.height).to.be.equal expected.height
          done()

      width.send 1024
      testutils.getBuffer __dirname + '/fixtures/lenna.png', (buffer) ->
        ins.send buffer

  describe 'when passed a path to image file', ->
    original =
      width: 512
      height: 512
    it 'should resize it to the specified dimension', (done) ->
      expected =
        width: 128
        height: 256
      out.on 'data', (data) ->
        buffer = sharp data
        buffer.metadata (err, meta) ->
          chai.expect(meta.width).to.be.equal expected.width
          chai.expect(meta.height).to.be.equal expected.height
          done()

      width.send expected.width
      height.send expected.height
      ins.send  __dirname + '/fixtures/foo.jpeg'

    it 'should resize it right when given just width', (done) ->
      expected =
        width: 128
      out.on 'data', (data) ->
        buffer = sharp data
        buffer.metadata (err, meta) ->
          chai.expect(meta.width).to.be.equal expected.width
          chai.expect(meta.height).to.be.equal expected.width
          done()

      width.send expected.width
      ins.send __dirname + '/fixtures/lenna.png'

    it 'should resize it right when given just height', (done) ->
      expected =
        height: 128
      out.on 'data', (data) ->
        buffer = sharp data
        buffer.metadata (err, meta) ->
          chai.expect(meta.width).to.be.equal expected.height
          chai.expect(meta.height).to.be.equal expected.height
          done()

      height.send expected.height
      ins.send __dirname + '/fixtures/lenna.png'

    it 'should resize it right to default dimension', (done) ->
      expected =
        width: 256
        height: 256
      out.on 'data', (data) ->
        buffer = sharp data
        buffer.metadata (err, meta) ->
          chai.expect(meta.width).to.be.equal expected.width
          chai.expect(meta.height).to.be.equal expected.height
          done()

      ins.send __dirname + '/fixtures/lenna.png'

