-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
81 lines (63 loc) · 2.42 KB
/
test.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
import assumeEnzyme from 'assume-enzyme';
import { shallow } from 'enzyme';
import assume from 'assume';
import React from 'react';
import Appetizer from './';
assume.use(assumeEnzyme);
describe('Appetizer Component', function () {
let app;
describe('#url', function () {
it('includes the key property in the url', function () {
app = shallow(<Appetizer public='what' />).instance();
assume(app.url()).to.equal('https://appetize.io/embed/what');
});
});
describe('#query', function () {
it('generates a query string', function () {
app = shallow(<Appetizer public='what' />).instance();
const query = app.query();
assume(query).is.a('string');
assume(query).startWith('?');
});
it('url encodes params', function () {
const params = { hello: 'world' };
app = shallow(<Appetizer public='what' params={ params } color='white' />).instance();
const query = app.query();
assume(query).includes('deviceColor=white');
assume(query).includes('params=' + encodeURIComponent(JSON.stringify(params)));
});
it('renames props to params', function () {
app = shallow(<Appetizer
language='en'
location='23.78934,41.38902'
version='0.7'
public='wut'
color='white'
link='whatever'
screen
adb
xdoc
/>).instance();
const query = app.query();
assume(query).to.include('xdocMsg=true');
assume(query).to.include('language=en');
assume(query).to.include('location=' + encodeURIComponent('23.78934,41.38902'));
assume(query).to.include('osVersion=0.7');
assume(query).to.include('deviceColor=white');
assume(query).to.include('screenOnly=true');
assume(query).to.include('launchUrl=whatever');
assume(query).to.include('enableAdb=true');
});
});
describe('#render', function () {
it('returns an iframe', function () {
app = shallow(<Appetizer public='what' color='white' />);
assume(app).to.have.tagName('iframe');
});
it('passes iframe props to the iframe', function () {
app = shallow(<Appetizer public='what' color='white' scrolling='no' frameborder='0' />);
assume(app).to.have.props({ scrolling: 'no', frameborder: '0' });
assume(app.props().src).to.equal('https://appetize.io/embed/what?device=iphone5s&scale=100&orientation=portrait&autoplay=false&deviceColor=white');
});
});
});