From b5e89c09b9c4b56f87123b13f315ab1446e9e709 Mon Sep 17 00:00:00 2001 From: Kylart Date: Tue, 2 Jul 2019 00:58:07 +0200 Subject: [PATCH] Setup chai with mocha Changed test kawanime directory condition --- src/background/server/utils/dir.js | 2 +- test/electron.spec.js | 29 +++++++++++++++++++++-------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/background/server/utils/dir.js b/src/background/server/utils/dir.js index cd8c265..631259d 100644 --- a/src/background/server/utils/dir.js +++ b/src/background/server/utils/dir.js @@ -1,6 +1,6 @@ import { app } from 'electron' import { join } from 'path' -export default process.env.NODE_ENV !== 'KawAnime-test' +export default process.env.IS_TEST !== 'true' ? join(app.getPath('userData'), 'appFiles') : join(app.getPath('home'), '.KawAnime-test') diff --git a/test/electron.spec.js b/test/electron.spec.js index c6b8a12..9683f59 100644 --- a/test/electron.spec.js +++ b/test/electron.spec.js @@ -1,9 +1,10 @@ -// const test = require('ava') +const { Application } = require('spectron') +const electron = require('electron') +const chai = require('chai') +const chaiAsPromised = require('chai-as-promised') -// A simple test to verify a visible window is opened with a title -var Application = require('spectron').Application -var electron = require('electron') -var assert = require('assert') +chai.should() +chai.use(chaiAsPromised) describe('Launch app', function () { this.timeout(10000) @@ -17,13 +18,25 @@ describe('Launch app', function () { return this.app.start() }) + beforeEach(function () { + chaiAsPromised.transferPromiseness = this.app.transferPromiseness + }) + after(async function () { this.app.stop() }) it('should be visible', async function () { - const isVisible = await this.app.browserWindow.isVisible() - - assert.strictEqual(true, isVisible) + return this.app.client + .getWindowCount() + .should.eventually.have.at.least(1) + .browserWindow.isMinimized() + .should.eventually.be.false.browserWindow.isVisible() + .should.eventually.be.true.browserWindow.getBounds() + .should.eventually.have.property('width') + .and.be.above(0) + .browserWindow.getBounds() + .should.eventually.have.property('height') + .and.be.above(0) }) })