+
Skip to content

Fixing tests #361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"postinstall": "node ../build/createDocumentnavigation.js && markdown-html resources/Documentation/WritingWithInk.md -s resources/Documentation/documentation.css -o renderer/documentation/embedded.html",
"start": "electron main-process/main.js",
"test": "./node_modules/mocha/bin/mocha",
"test": "node ./node_modules/mocha/bin/mocha",
"generate-locale": "node ../build/generateLocale.js"
},
"repository": {
Expand All @@ -31,8 +31,8 @@
"electron": "^4.2.0",
"jsdom": "^16.5.1",
"markdown-html": "^0.0.8",
"mocha": "^4.0.1",
"spectron": "^3.8.0"
"mocha": "^9.0.1",
"spectron": "^6.0.0"
},
"dependencies": {
"chokidar": "^3.3.1",
Expand Down
78 changes: 46 additions & 32 deletions app/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,81 +10,95 @@ const inkyPathsByPlatform = {
"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 () {
this.app = new Application({
path: inkyPathsByPlatform[process.platform]
})
return this.app.start().then(function (app) {
chaiAsPromised.transferPromiseness = app.transferPromiseness;
return app;
});
chaiAsPromised.transferPromiseness = app.transferPromiseness;
return app.start();
})

afterEach(function () {
if (this.app && this.app.isRunning()) {
return this.app.stop()
if (app && app.isRunning()) {
app.mainProcess.exit(0);
}
})

it('shows an initial window', function () {
return this.app.client.getWindowCount().then(function (count) {
assert.equal(count, 1)
})
return app.client
.getWindowCount()
.should.eventually.equal(1);
})

it('reads the title', function () {
const title = "Untitled.ink";
return this.app.client.getText('.title')

return app.client
.getHTML('.title', false)
.should.eventually.equal(title);
})

it('opens the menu', function () {
return this.app.client.click('.icon-menu')
.element('.sidebar')
.should.eventually.exist
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 () {
this.app = new Application({
path: inkyPathsByPlatform[process.platform]
})
return this.app.start().then(function (app) {
chaiAsPromised.transferPromiseness = app.transferPromiseness;
return app;
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 (this.app && this.app.isRunning()) {
return this.app.stop()
if (app && app.isRunning()) {
app.mainProcess.exit(0);
}
})

it('writes and reads hello world', function () {
const input = "Hello World!";
return this.app.client

return app.client
.setValue('.ace_text-input', input)
.pause(2000)
.getText('.storyText')
.should.eventually.equal(input)
.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 this.app.client
return app.client
.setValue('.ace_text-input', input)
.pause(2000)
.click('.choice')
Expand All @@ -99,19 +113,19 @@ describe('compiles hello world game', function () {
const input = "Hello World! \n * [Hello back] \n Nice to hear from you! \n -> END";
const resultAnswer = "Nice to hear from you!";

return this.app.client
return app.client
.setValue('.ace_text-input', input)
.pause(2000)
.click('.choice')
.pause(2000)
.getText('.storyText:nth-of-type(2)')
.should.eventually.equal(resultAnswer)
.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 this.app.client
return app.client
.setValue('.ace_text-input', input)
.pause(2000)
.getText('.issuesMessage')
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载