Skip to content

Commit

Permalink
✅ test: improve fieldImage tests
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed May 9, 2016
1 parent c1c57be commit a5d714d
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/unit/specs/fields/fieldImage.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,37 @@ describe("fieldImage.vue", () => {
});
});

it("should convert image to base64 if file input changed", (done) => {
// Stub the browser FileReader
let FR = window.FileReader;
window.FileReader = sinon.stub().returns({
readAsDataURL(file) {
this.onload({
target: {
result: "base64 image data"
}
});
}
});
field.fileChanged({
target: {
files: [
{
name: "test.jpg",
length: 55431
}
]
}
});

vm.$nextTick( () => {
let remove = el.querySelector(".remove");
expect(input.value).to.be.equal("base64 image data");
expect(model.avatar).to.be.equal("base64 image data");
done();
});
});

});

});

0 comments on commit a5d714d

Please sign in to comment.