diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 800d694..0000000 --- a/test/test.js +++ /dev/null @@ -1,112 +0,0 @@ -'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'; -const TABS_ID = '#tabs'; -const REGEX_PNG = /^data:image\/png;base64,/; - -describe.skip('Negative', function () { - const app = new Application({ - path: APP_PATH, - env: { - ELECTRON_ENABLE_LOGGING: true, - ELECTRON_ENABLE_STACK_DUMPING: true, - NEGATIVE_IGNORE_WINDOW_SETTINGS: true, - NEGATIVE_SKIP_RESET_DIALOG: true, - NODE_ENV: 'development' - } - }); - - this.timeout(60000); - - /** - * Reset all windows. - */ - function reset() { - return app.electron.ipcRenderer.send('test-reset') - .then(() => app.client.windowHandles()) - .then((handles) => app.client.window(handles.value[0])); - } - - beforeEach(() => { - return app.start(); - }); - - afterEach(() => { - if (app && app.isRunning()) { - return app.stop(); - } - }); - - describe('Menues', () => { - describe('View', () => { - it('Actual Size', () => { - return app.electron.ipcRenderer.send('test-capture') - .then(() => 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)); - }); - - it('Zoom In', () => { - return app.electron.ipcRenderer.send('test-capture') - .then(() => app.electron.ipcRenderer.send('test-actual-size')) - .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, 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)); - }); - - it('Zoom Out', () => { - return app.electron.ipcRenderer.send('test-capture') - .then(() => app.electron.ipcRenderer.send('test-actual-size')) - .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.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)); - }); - }); - }); -}); - diff --git a/test/tests/benchmark.js b/test/tests/benchmark.js index 464e803..3afcdc0 100644 --- a/test/tests/benchmark.js +++ b/test/tests/benchmark.js @@ -39,4 +39,4 @@ describe.skip('Benchmark', function () { }); }); }) -}); \ No newline at end of file +}); diff --git a/test/tests/menu/edit/copy.js b/test/tests/menu/edit/copy.js index 2c5e6e6..f09af39 100644 --- a/test/tests/menu/edit/copy.js +++ b/test/tests/menu/edit/copy.js @@ -38,4 +38,4 @@ describe('Edit > Copy', function () { assert.isDefined(image.getSize); }); }); -}); \ No newline at end of file +}); diff --git a/test/tests/menu/edit/paste.js b/test/tests/menu/edit/paste.js index 290e399..ae3f626 100644 --- a/test/tests/menu/edit/paste.js +++ b/test/tests/menu/edit/paste.js @@ -39,4 +39,4 @@ describe('Edit > Paste', function () { }) .then((src) => assert.isTrue(REGEX_PNG.test(src))); }); -}); \ No newline at end of file +}); diff --git a/test/tests/menu/edit/redo.js b/test/tests/menu/edit/redo.js index e9f28b6..3d05c73 100644 --- a/test/tests/menu/edit/redo.js +++ b/test/tests/menu/edit/redo.js @@ -39,4 +39,4 @@ describe('Edit > Redo', function () { }) .then((src) => assert.isTrue(REGEX_PNG.test(src))); }); -}); \ No newline at end of file +}); diff --git a/test/tests/menu/edit/undo.js b/test/tests/menu/edit/undo.js index c76345b..645b45a 100644 --- a/test/tests/menu/edit/undo.js +++ b/test/tests/menu/edit/undo.js @@ -38,4 +38,4 @@ describe('Edit > Undo', function () { }) .then((src) => assert.equal(src, '')); }); -}); \ No newline at end of file +}); diff --git a/test/tests/menu/file/close-tab.js b/test/tests/menu/file/close-tab.js index 20a91ff..f15e9e6 100644 --- a/test/tests/menu/file/close-tab.js +++ b/test/tests/menu/file/close-tab.js @@ -42,4 +42,4 @@ describe('File > Close Tab', function () { }) .then((tabCount) => assert.equal(tabCount, 1)); }); -}); \ No newline at end of file +}); diff --git a/test/tests/menu/file/close-window.js b/test/tests/menu/file/close-window.js index 2458e54..0ecb557 100644 --- a/test/tests/menu/file/close-window.js +++ b/test/tests/menu/file/close-window.js @@ -37,4 +37,4 @@ describe('File > Close Window', function () { .then(() => app.client.getWindowCount()) .then((count) => assert.equal(count, 1)); }); -}); \ No newline at end of file +}); diff --git a/test/tests/menu/file/new-tab.js b/test/tests/menu/file/new-tab.js index bf272ec..c292b2f 100644 --- a/test/tests/menu/file/new-tab.js +++ b/test/tests/menu/file/new-tab.js @@ -41,4 +41,4 @@ describe('File > New Tab', function () { }) .then((tabCount) => assert.equal(tabCount, 2)); }); -}); \ No newline at end of file +}); diff --git a/test/tests/menu/file/new-window.js b/test/tests/menu/file/new-window.js index ca14c97..27e8dc7 100644 --- a/test/tests/menu/file/new-window.js +++ b/test/tests/menu/file/new-window.js @@ -34,4 +34,4 @@ describe('File > New Window', function () { .then(() => app.client.getWindowCount()) .then((count) => assert.equal(count, 2)); }); -}); \ No newline at end of file +}); diff --git a/test/tests/menu/negative/preferences.js b/test/tests/menu/negative/preferences.js index 38a6c78..b84ee0e 100644 --- a/test/tests/menu/negative/preferences.js +++ b/test/tests/menu/negative/preferences.js @@ -80,4 +80,4 @@ describe('Negative > Preferences', function () { // `performSelector`, it cannot be properly tested until // Spectron supports testing menu item functionality. it('Close'); -}); \ No newline at end of file +}); diff --git a/test/tests/menu/negative/quit.js b/test/tests/menu/negative/quit.js index 889f1d7..9f5718b 100644 --- a/test/tests/menu/negative/quit.js +++ b/test/tests/menu/negative/quit.js @@ -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())); }); -}); \ No newline at end of file +}); diff --git a/test/tests/menu/negative/reset.js b/test/tests/menu/negative/reset.js index a0f11c1..0c9600f 100644 --- a/test/tests/menu/negative/reset.js +++ b/test/tests/menu/negative/reset.js @@ -37,4 +37,4 @@ describe('Negative > Reset...', function () { .then(() => app.client.getWindowCount()) .then((count) => assert.strictEqual(count, 1)); }); -}); \ No newline at end of file +}); diff --git a/test/tests/menu/view/actual-size.js b/test/tests/menu/view/actual-size.js new file mode 100644 index 0000000..fa1e486 --- /dev/null +++ b/test/tests/menu/view/actual-size.js @@ -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)); + }); +}); diff --git a/test/tests/menu/view/capture.js b/test/tests/menu/view/capture.js index 3676f2e..f92fe4d 100644 --- a/test/tests/menu/view/capture.js +++ b/test/tests/menu/view/capture.js @@ -38,4 +38,4 @@ describe('View > Capture', function () { }) .then((src) => assert.isTrue(REGEX_PNG.test(src))); }); -}); \ No newline at end of file +}); diff --git a/test/tests/menu/view/clear.js b/test/tests/menu/view/clear.js index 8a9ee44..55bd385 100644 --- a/test/tests/menu/view/clear.js +++ b/test/tests/menu/view/clear.js @@ -38,4 +38,4 @@ describe('View > Clear', function () { }) .then((src) => assert.equal(src, '')); }); -}); \ No newline at end of file +}); diff --git a/test/tests/menu/view/zoom-in.js b/test/tests/menu/view/zoom-in.js new file mode 100644 index 0000000..39a3caf --- /dev/null +++ b/test/tests/menu/view/zoom-in.js @@ -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)); + }); +}); diff --git a/test/tests/menu/view/zoom-out.js b/test/tests/menu/view/zoom-out.js new file mode 100644 index 0000000..7f801f5 --- /dev/null +++ b/test/tests/menu/view/zoom-out.js @@ -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)); + }); +}); diff --git a/test/tests/menu/window/fit-window-to-image.js b/test/tests/menu/window/fit-window-to-image.js index b2d8301..ab3f915 100644 --- a/test/tests/menu/window/fit-window-to-image.js +++ b/test/tests/menu/window/fit-window-to-image.js @@ -50,4 +50,4 @@ describe('Window > Fit Window to Image', function () { assert.strictEqual(origBounds.height, bounds.height); }); }); -}); \ No newline at end of file +}); diff --git a/test/tests/menu/window/move.js b/test/tests/menu/window/move.js index 3d59c15..6211571 100644 --- a/test/tests/menu/window/move.js +++ b/test/tests/menu/window/move.js @@ -87,4 +87,4 @@ describe('Window > Move', function () { return testBounds('down', 10) .then((result) => assert.strictEqual(result.newBounds.y, result.oldBounds.y + 10)); }); -}); \ No newline at end of file +}); diff --git a/test/tests/menu/window/next-tab-and-resize.js b/test/tests/menu/window/next-tab-and-resize.js index d912fca..5462f45 100644 --- a/test/tests/menu/window/next-tab-and-resize.js +++ b/test/tests/menu/window/next-tab-and-resize.js @@ -54,4 +54,4 @@ describe('Window > Next Tab And Resize', function () { assert.strictEqual(firstTabBounds.height, bounds.height); }); }); -}); \ No newline at end of file +}); diff --git a/test/tests/menu/window/next-tab.js b/test/tests/menu/window/next-tab.js index 0bde836..a32cb89 100644 --- a/test/tests/menu/window/next-tab.js +++ b/test/tests/menu/window/next-tab.js @@ -47,4 +47,4 @@ describe('Window > Next Tab', function () { }) .then((selectedIndex) => assert.equal(selectedIndex, 0)) }); -}); \ No newline at end of file +}); diff --git a/test/tests/menu/window/previous-tab-and-resize.js b/test/tests/menu/window/previous-tab-and-resize.js index a5a28b3..ecdb4af 100644 --- a/test/tests/menu/window/previous-tab-and-resize.js +++ b/test/tests/menu/window/previous-tab-and-resize.js @@ -54,4 +54,4 @@ describe('Window > Previous Tab And Resize', function () { assert.strictEqual(firstTabBounds.height, bounds.height); }); }); -}); \ No newline at end of file +}); diff --git a/test/tests/menu/window/previous-tab.js b/test/tests/menu/window/previous-tab.js index faca869..cef648a 100644 --- a/test/tests/menu/window/previous-tab.js +++ b/test/tests/menu/window/previous-tab.js @@ -47,4 +47,4 @@ describe('Window > Previous Tab', function () { }) .then((selectedIndex) => assert.equal(selectedIndex, 0)) }); -}); \ No newline at end of file +});