-
Notifications
You must be signed in to change notification settings - Fork 332
Expand file tree
/
Copy pathtest.js
More file actions
135 lines (107 loc) · 3.49 KB
/
Copy pathtest.js
File metadata and controls
135 lines (107 loc) · 3.49 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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
const Application = require('spectron').Application
const assert = require('assert')
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
const inkyPathsByPlatform = {
"darwin": "../Inky-darwin-x64/Inky.app/Contents/MacOS/Inky",
"linux": "../Inky-linux-x64/Inky",
"win32": "../Inky-win32-x64/Inky.exe"
};
const app = new Application({
path: inkyPathsByPlatform[process.platform]
})
chai.should();
chai.use(chaiAsPromised);
describe('application launch tests', function () {
this.timeout(10000)
beforeEach(function () {
chaiAsPromised.transferPromiseness = app.transferPromiseness;
return app.start();
})
afterEach(function () {
if (app && app.isRunning()) {
app.mainProcess.exit(0);
}
})
it('shows an initial window', function () {
return app.client
.getWindowCount()
.should.eventually.equal(1);
})
it('reads the title', function () {
const title = "Untitled.ink";
return app.client
.getHTML('.title', false)
.should.eventually.equal(title);
})
it('opens the menu', function () {
const cssPropValue = "block";
return app.client
.click('.icon-menu')
.getCssProperty('.sidebar','display').then(function (property){
return property.value;
}).should.eventually.equal(cssPropValue);
})
})
describe('compiles hello world game', function () {
this.timeout(10000)
beforeEach(function () {
chaiAsPromised.transferPromiseness = app.transferPromiseness;
return app.start().then(function () {
// A bug with setValue() means it doesn't properly clear the element
// hence the element is cleared by simulating pressing the delete key
for (let i = 0; i < 125; i++) {
app.client.setValue('.ace_text-input', "\ue017").pause(50);
};
return app.client.setValue('.ace_text-input', "\ue017");
});
})
afterEach(function () {
if (app && app.isRunning()) {
app.mainProcess.exit(0);
}
})
it('writes and reads hello world', function () {
const input = "Hello World!";
return app.client
.setValue('.ace_text-input', input)
.pause(2000)
.getText('.storyText:nth-of-type(1)').then(function(value){
return value.join('');
})
.should.eventually.equal(input);
})
it('writes and selects a choice', function () {
const input = "Hello World! \n * Hello back \n Nice to hear from you! \n -> END";
const resultChoice = "Hello back";
const resultAnswer = "Nice to hear from you!";
return app.client
.setValue('.ace_text-input', input)
.pause(2000)
.click('.choice')
.pause(2000)
.getText('.storyText:nth-of-type(2)')
.should.eventually.equal(resultChoice)
.getText('.storyText:nth-of-type(3)')
.should.eventually.equal(resultAnswer)
})
it('suppresses choice text', function () {
const input = "Hello World! \n * [Hello back] \n Nice to hear from you! \n -> END";
const resultAnswer = "Nice to hear from you!";
return app.client
.setValue('.ace_text-input', input)
.pause(2000)
.click('.choice')
.pause(2000)
.getText('.storyText:nth-of-type(3)')
.should.eventually.equal(resultAnswer);
})
it('shows TODOs', function() {
const input = "-\n * Rock\n * Paper\n * Scissors\nTODO: Make this more interesting"
return app.client
.setValue('.ace_text-input', input)
.pause(2000)
.getText('.issuesMessage')
.should.eventually.not.equal('No issues.')
})
})