/
groovyTest.js
116 lines (95 loc) · 3.56 KB
/
groovyTest.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
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
/*
* Copyright 2017 TWO SIGMA OPEN SOURCE, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var BeakerXPageObject = require('../beakerx.po.js');
var beakerxPO;
describe('Groovy tests', function () {
beforeAll(function () {
beakerxPO = new BeakerXPageObject();
beakerxPO.runNotebookByUrl('/notebooks/test/notebooks/groovy/GroovyTest.ipynb');
}, 2);
afterAll(function () {
beakerxPO.closeAndHaltNotebook();
});
describe('Run first cell. ', function () {
it('Output contains "2"', function () {
beakerxPO.runCellAndCheckOutputText(0, '2');
});
});
describe('Run 2nd cell. ', function () {
it('Output contains "groovy.lang.MissingPropertyException"', function () {
beakerxPO.runCellAndCheckOutputText(1, 'groovy.lang.MissingPropertyException');
});
}, 2);
describe('Run 3rd cell. ', function () {
it('Output contains "2"', function () {
beakerxPO.runCellAndCheckOutputText(2, '2');
});
}, 2);
describe('Run 4th cell. ', function () {
it('Output contains "run_closure"', function () {
beakerxPO.runCellAndCheckOutputText(3, 'run_closure');
});
}, 2);
describe('Run 5th cell. ', function () {
it('Output contains "8"', function () {
beakerxPO.runCellAndCheckOutputText(4, '8');
});
}, 2);
describe('Run 6th cell. ', function () {
it('Output contains "Multiplying Strings!Multiplying Strings!"', function () {
beakerxPO.runCellAndCheckOutputText(5, 'Multiplying Strings!Multiplying Strings!');
});
}, 2);
describe('Run 7th cell. ', function () {
it('Output contains "9.265"', function () {
beakerxPO.runCellAndCheckOutputText(6, '9.265');
});
}, 2);
function checkCyrilicString(str){
expect(str.charCodeAt(0).toString(16)).toEqual('44d');
expect(str.charCodeAt(1).toString(16)).toEqual('44e');
expect(str.charCodeAt(2).toString(16)).toEqual('44f');
}
describe('Cyrillic symbols (Groovy) ', function () {
var codeCell;
it('Output contains UTF-8 hex string', function () {
codeCell = beakerxPO.runCodeCellByIndex(7);
beakerxPO.waitAndCheckCellOutputStdoutText(7, /d18dd18ed18f/);
});
it('Plot title is cyrillic (cp1521)', function () {
checkCyrilicString(codeCell.$('div#plotTitle').getText());
});
it('Plot x label is cyrillic (utf8 from cp1521)', function () {
var svg = codeCell.$('#svgg');
checkCyrilicString(svg.$('text#xlabel').getText());
});
it('Plot y label is cyrillic (utf-8)', function () {
var svg = codeCell.$('#svgg');
checkCyrilicString(svg.$('text#ylabel').getText());
});
}, 2);
describe('getCodeCells(tag) method', function () {
it('Tag cell output contains "5"', function(){
beakerxPO.runCellAndCheckOutputText(8, '5');
});
it('Output contains table', function () {
var codeCell = beakerxPO.runCodeCellByIndex(9);
var bkoTable = codeCell.$('div.bko-table');
expect(bkoTable.isEnabled()).toBeTruthy();
expect(bkoTable.$('tbody > tr').getText()).toMatch('"text/plain":"5"');
});
}, 2);
});