Initial commit
This commit is contained in:
40
spec/javascript/active_storage_dropzone.spec.js
Normal file
40
spec/javascript/active_storage_dropzone.spec.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import ActiveStorageDropzone from "active_storage_dropzone";
|
||||
const $ = require('jquery');
|
||||
|
||||
describe("ActiveStorageDropzone", () => {
|
||||
class FakeDropzone {
|
||||
constructor(element, options) {
|
||||
this.element = element
|
||||
this.options = options
|
||||
}
|
||||
emit() {}
|
||||
createThumbnailFromUrl() {}
|
||||
}
|
||||
|
||||
class FakeUploader {
|
||||
constructor(file, url, delegate) {
|
||||
this.file = file
|
||||
this.url = url
|
||||
this.delegate = delegate
|
||||
}
|
||||
}
|
||||
|
||||
describe("init", () => {
|
||||
it("creates a dropzone with custom settings", () => {
|
||||
const data = [{"name":"filename","size":123,"type":"image/jpg","dataURL":"url-to-asset"}]
|
||||
|
||||
document.body.innerHTML =
|
||||
`<div class="test" data-existing-files='${JSON.stringify(data)}'>` +
|
||||
'</div>';
|
||||
|
||||
const dropzone = new ActiveStorageDropzone(FakeDropzone, FakeUploader)
|
||||
dropzone.init($(".test"))
|
||||
|
||||
expect(dropzone.myDropzone.options.url).toBe("/")
|
||||
expect(dropzone.myDropzone.options.autoQueue).toBe(true)
|
||||
expect(dropzone.myDropzone.options.acceptedFiles).toBe("image/*")
|
||||
expect(dropzone.myDropzone.options.parallelUploads).toBe(30)
|
||||
expect(dropzone.myDropzone.options.dictDefaultMessage).toBe("Drop files here")
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user