-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
FileUploader.js
88 lines (67 loc) · 2.39 KB
/
FileUploader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
var FileUploader = require('asset_manager/view/FileUploader');
module.exports = {
run() {
describe('File Uploader', () => {
before(function () {
this.$fixtures = $("#fixtures");
this.$fixture = $('<div class="fileupload-fixture"></div>');
});
beforeEach(function () {
this.view = new FileUploader({ config : {} });
this.$fixture.empty().appendTo(this.$fixtures);
this.$fixture.html(this.view.render().el);
});
afterEach(function () {
this.view.remove();
});
after(function () {
this.$fixture.remove();
});
it('Object exists', () => {
expect(FileUploader).toExist();
});
it('Has correct prefix', function() {
expect(this.view.pfx).toNotExist();
});
describe('Should be rendered correctly', () => {
it('Has title', function() {
expect(this.view.$el.find('#title').length).toEqual(1);
});
it('Title is empty', function() {
expect(this.view.$el.find('#title').html()).toEqual('');
});
it('Has file input', function() {
expect(this.view.$el.find('input[type=file]').length).toEqual(1);
});
it('File input is enabled', function() {
expect(this.view.$el.find('input[type=file]').prop('disabled')).toEqual(true);
});
});
describe('Interprets configurations correctly', () => {
it('Has correct title', () => {
var view = new FileUploader({ config : {
uploadText : 'Test',
} });
view.render();
expect(view.$el.find('#title').html()).toEqual('Test');
});
it('Could be disabled', () => {
var view = new FileUploader({ config : {
disabled: true,
upload: 'something'
} });
view.render();
expect(view.$el.find('input[type=file]').prop('disabled')).toEqual(true);
});
it('Handles embedAsBase64 parameter', () => {
var view = new FileUploader({ config : {
embedAsBase64: true
} });
view.render();
expect(view.$el.find('input[type=file]').prop('disabled')).toEqual(false);
expect(view.uploadFile).toEqual(FileUploader.embedAsBase64);
});
});
});
}
}