-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowser-test.html
119 lines (79 loc) · 2.62 KB
/
browser-test.html
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<html>
<head>
<meta charset="UTF-8">
<script src="dist/flexio.min.js"></script>
<script>function require(){return Flexio};module={exports:{}}</script>
<script src="sdk-test-config.js"></script>
</head>
<body>
<script>
function onRunCustomTest(input)
{
Flexio.setup('xtdkxpcjwzkpgkhkcmhx', { host: 'localhost', debug: true, insecure: true });
var pipe = eval(document.getElementById('input').value)
pipe.run({query:{name:'World'}}).then(response => {
document.getElementById('output').value = response.text
})
}
</script>
<p>This small html file tests some aspects of the Flex.io SDK which are browser-specific</p>
<p>
<form>
<textarea id="input" name="input" type="text" rows=8 cols=80 autofocus>
Flexio.pipe()
.javascript(function(context) {
context.output.write('Hello ' + context.query.name + '!')
})
</textarea>
<br/>
<button type="button" onclick="onRunCustomTest()">Run</button>
<br/>
<textarea id="output" name="output" type="text" rows=10 cols=80></textarea><br/><br/>
</form>
</p>
<p>
<form>
<button type="button" onclick="onRunTests()">Run Tests</button>
</form>
</p>
<p>
<div id="testoutput"></div>
</p>
<script>
var tests = []
tests.push(async function testQueryString() {
var pipe = Flexio.pipe()
.javascript(function(context) {
context.output.write('Hello ' + context.query.name + '!')
})
var response = await pipe.run({ query: { name: 'World' } })
var result = response.text
return (result === "Hello World!")
})
tests.push(async function testPostData() {
var form = new FormData();
form.append('name', 'World');
var pipe = Flexio.pipe()
.echo('Hello ${form.name}!')
var response = await pipe.run({ data: form })
var result = response.text
return (result === "Hello World!")
})
async function runTest(funcptr)
{
document.getElementById("testoutput").innerHTML = ''
var result = await funcptr()
var str = "<pre>" + funcptr.name + " - " + (result ? "PASSED": "FAILED") + "</pre>"
document.getElementById("testoutput").innerHTML += str
}
function onRunTests()
{
(async function() {
for (var i = 0; i < tests.length; ++i) {
runTest(tests[i])
}
})()
}
</script>
</body>
</html>