-
Notifications
You must be signed in to change notification settings - Fork 399
Expand file tree
/
Copy pathweb.test.js
More file actions
79 lines (64 loc) · 2.33 KB
/
Copy pathweb.test.js
File metadata and controls
79 lines (64 loc) · 2.33 KB
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
/* global describe, beforeEach, it, before, afterEach, after, chai */
/* eslint no-console: 0 */
import { expect } from 'chai';
import PubNub from '../../src/web';
var pubnub;
describe('#distribution test (web)', function () {
before(function () {
pubnub = new PubNub({
subscribeKey: 'demo',
publishKey: 'demo',
uuid: 'myUUID',
});
});
after(function () {
pubnub.destroy();
});
describe('#File', function () {
it('should have access to File property on pubnub instance', function () {
expect(pubnub.File).to.be.a('function');
expect(pubnub.File).to.have.property('create');
});
it('should be able to create a PubNubFile using pubnub.File.create() with data object', function () {
var fileData = {
data: 'Hello World',
name: 'test.txt',
mimeType: 'text/plain',
};
var file = pubnub.File.create(fileData);
expect(file).to.be.an('object');
expect(file).to.have.property('name').equal('test.txt');
expect(file).to.have.property('mimeType').equal('text/plain');
expect(file).to.have.property('data');
});
it('should be able to create a PubNubFile using pubnub.File.create() with Blob', function () {
var blob = new Blob(['test content'], { type: 'text/plain' });
var fileData = {
data: blob,
name: 'blob-test.txt',
mimeType: 'text/plain',
};
var file = pubnub.File.create(fileData);
expect(file).to.be.an('object');
expect(file).to.have.property('name').equal('blob-test.txt');
expect(file).to.have.property('mimeType').equal('text/plain');
});
it('should be able to create a PubNubFile using pubnub.File.create() with ArrayBuffer', function () {
var buffer = new ArrayBuffer(8);
var fileData = {
data: buffer,
name: 'buffer-test.bin',
mimeType: 'application/octet-stream',
};
var file = pubnub.File.create(fileData);
expect(file).to.be.an('object');
expect(file).to.have.property('name').equal('buffer-test.bin');
expect(file).to.have.property('mimeType').equal('application/octet-stream');
});
it('should throw error when creating PubNubFile without required parameters', function () {
expect(function () {
pubnub.File.create({});
}).to.throw();
});
});
});