Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Merge pull request #100 from atdrago/feature/adam/testing
Browse files Browse the repository at this point in the history
Feature/adam/testing
  • Loading branch information
atdrago committed May 21, 2016
2 parents db7fafb + ce88db1 commit 86c8368
Show file tree
Hide file tree
Showing 24 changed files with 179 additions and 132 deletions.
112 changes: 0 additions & 112 deletions test/test.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/tests/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ describe.skip('Benchmark', function () {
});
});
})
});
});
2 changes: 1 addition & 1 deletion test/tests/menu/edit/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ describe('Edit > Copy', function () {
assert.isDefined(image.getSize);
});
});
});
});
2 changes: 1 addition & 1 deletion test/tests/menu/edit/paste.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ describe('Edit > Paste', function () {
})
.then((src) => assert.isTrue(REGEX_PNG.test(src)));
});
});
});
2 changes: 1 addition & 1 deletion test/tests/menu/edit/redo.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ describe('Edit > Redo', function () {
})
.then((src) => assert.isTrue(REGEX_PNG.test(src)));
});
});
});
2 changes: 1 addition & 1 deletion test/tests/menu/edit/undo.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ describe('Edit > Undo', function () {
})
.then((src) => assert.equal(src, ''));
});
});
});
2 changes: 1 addition & 1 deletion test/tests/menu/file/close-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ describe('File > Close Tab', function () {
})
.then((tabCount) => assert.equal(tabCount, 1));
});
});
});
2 changes: 1 addition & 1 deletion test/tests/menu/file/close-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ describe('File > Close Window', function () {
.then(() => app.client.getWindowCount())
.then((count) => assert.equal(count, 1));
});
});
});
2 changes: 1 addition & 1 deletion test/tests/menu/file/new-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ describe('File > New Tab', function () {
})
.then((tabCount) => assert.equal(tabCount, 2));
});
});
});
2 changes: 1 addition & 1 deletion test/tests/menu/file/new-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ describe('File > New Window', function () {
.then(() => app.client.getWindowCount())
.then((count) => assert.equal(count, 2));
});
});
});
2 changes: 1 addition & 1 deletion test/tests/menu/negative/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ describe('Negative > Preferences', function () {
// `performSelector`, it cannot be properly tested until
// Spectron supports testing menu item functionality.
it('Close');
});
});
2 changes: 1 addition & 1 deletion test/tests/menu/negative/quit.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ describe('Negative > Quit', function () {
// @TODO - This should test that settings are saved (or at least written)
return app.stop().then(() => assert.isFalse(app.isRunning()));
});
});
});
2 changes: 1 addition & 1 deletion test/tests/menu/negative/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ describe('Negative > Reset...', function () {
.then(() => app.client.getWindowCount())
.then((count) => assert.strictEqual(count, 1));
});
});
});
47 changes: 47 additions & 0 deletions test/tests/menu/view/actual-size.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict';

const { Application } = require('spectron');
const { assert } = require('chai');

const APP_PATH = './dist/Negative-darwin-x64/Negative.app/Contents/MacOS/Negative';
const IMAGE_ID = '#negativeImage';

describe('View > Actual Size', function () {
const app = new Application({
path: APP_PATH,
env: {
ELECTRON_ENABLE_LOGGING: true,
ELECTRON_ENABLE_STACK_DUMPING: true,
NEGATIVE_IGNORE_WINDOW_SETTINGS: false,
NEGATIVE_SKIP_RESET_DIALOG: true,
NEGATIVE_SETTINGS_PATH: '../test/fixtures/two-windows-with-data.json',
NODE_ENV: 'development'
}
});

this.timeout(60000);

beforeEach(() => {
return app.start();
});

afterEach(() => {
if (app && app.isRunning()) {
return app.stop();
}
});

it('Should zoom to 0', () => {
// @TODO - Load settings file for actual size. Blocked by #96.
return app.electron.ipcRenderer.send('test-zoom-in')
.then(() => app.electron.ipcRenderer.send('test-actual-size'))
.then(() => {
return app.client.selectorExecute(IMAGE_ID, (element) => {
const zoomLevel = element[0].getAttribute('data-zoom-level');

return zoomLevel;
});
})
.then((zoomLevel) => assert.equal(zoomLevel, 1));
});
});
2 changes: 1 addition & 1 deletion test/tests/menu/view/capture.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ describe('View > Capture', function () {
})
.then((src) => assert.isTrue(REGEX_PNG.test(src)));
});
});
});
2 changes: 1 addition & 1 deletion test/tests/menu/view/clear.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ describe('View > Clear', function () {
})
.then((src) => assert.equal(src, ''));
});
});
});
57 changes: 57 additions & 0 deletions test/tests/menu/view/zoom-in.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
'use strict';

const { Application } = require('spectron');
const { assert } = require('chai');

const APP_PATH = './dist/Negative-darwin-x64/Negative.app/Contents/MacOS/Negative';
const IMAGE_ID = '#negativeImage';

describe('View > Zoom In', function () {
const app = new Application({
path: APP_PATH,
env: {
ELECTRON_ENABLE_LOGGING: true,
ELECTRON_ENABLE_STACK_DUMPING: true,
NEGATIVE_IGNORE_WINDOW_SETTINGS: false,
NEGATIVE_SKIP_RESET_DIALOG: true,
NEGATIVE_SETTINGS_PATH: '../test/fixtures/two-windows-with-data.json',
NODE_ENV: 'development'
}
});

this.timeout(60000);

beforeEach(() => {
return app.start();
});

afterEach(() => {
if (app && app.isRunning()) {
return app.stop();
}
});

it('Should zoom in', () => {
return app.electron.ipcRenderer.send('test-zoom-in')
.then(() => {
return app.client.selectorExecute(IMAGE_ID, (element) => {
const zoomLevel = element[0].getAttribute('data-zoom-level');

return zoomLevel;
});
})
.then((zoomLevel) => assert.equal(zoomLevel, 1.25))
.then(() => app.electron.ipcRenderer.send('test-zoom-in'))
.then(() => app.electron.ipcRenderer.send('test-zoom-in'))
.then(() => app.electron.ipcRenderer.send('test-zoom-in'))
.then(() => app.electron.ipcRenderer.send('test-zoom-in'))
.then(() => {
return app.client.selectorExecute(IMAGE_ID, (element) => {
const zoomLevel = element[0].getAttribute('data-zoom-level');

return zoomLevel;
});
})
.then((zoomLevel) => assert.equal(zoomLevel, 2));
});
});
55 changes: 55 additions & 0 deletions test/tests/menu/view/zoom-out.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
'use strict';

const { Application } = require('spectron');
const { assert } = require('chai');

const APP_PATH = './dist/Negative-darwin-x64/Negative.app/Contents/MacOS/Negative';
const IMAGE_ID = '#negativeImage';

describe('View > Zoom Out', function () {
const app = new Application({
path: APP_PATH,
env: {
ELECTRON_ENABLE_LOGGING: true,
ELECTRON_ENABLE_STACK_DUMPING: true,
NEGATIVE_IGNORE_WINDOW_SETTINGS: false,
NEGATIVE_SKIP_RESET_DIALOG: true,
NEGATIVE_SETTINGS_PATH: '../test/fixtures/two-windows-with-data.json',
NODE_ENV: 'development'
}
});

this.timeout(60000);

beforeEach(() => {
return app.start();
});

afterEach(() => {
if (app && app.isRunning()) {
return app.stop();
}
});

it('Should zoom out', () => {
return app.electron.ipcRenderer.send('test-zoom-out')
.then(() => {
return app.client.selectorExecute(IMAGE_ID, (element) => {
const zoomLevel = element[0].getAttribute('data-zoom-level');

return zoomLevel;
});
})
.then((zoomLevel) => assert.equal(zoomLevel, 0.75))
.then(() => app.electron.ipcRenderer.send('test-zoom-out'))
.then(() => app.electron.ipcRenderer.send('test-zoom-out'))
.then(() => {
return app.client.selectorExecute(IMAGE_ID, (element) => {
const zoomLevel = element[0].getAttribute('data-zoom-level');

return zoomLevel;
});
})
.then((zoomLevel) => assert.equal(zoomLevel, 0.5));
});
});
2 changes: 1 addition & 1 deletion test/tests/menu/window/fit-window-to-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ describe('Window > Fit Window to Image', function () {
assert.strictEqual(origBounds.height, bounds.height);
});
});
});
});
2 changes: 1 addition & 1 deletion test/tests/menu/window/move.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ describe('Window > Move', function () {
return testBounds('down', 10)
.then((result) => assert.strictEqual(result.newBounds.y, result.oldBounds.y + 10));
});
});
});
2 changes: 1 addition & 1 deletion test/tests/menu/window/next-tab-and-resize.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ describe('Window > Next Tab And Resize', function () {
assert.strictEqual(firstTabBounds.height, bounds.height);
});
});
});
});
Loading

0 comments on commit 86c8368

Please sign in to comment.