index.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * @author oldj
  3. * @blog https://oldj.net
  4. */
  5. 'use strict';
  6. const path = require('path');
  7. const {test} = require('ava');
  8. const assert = require('assert');
  9. const Application = require('spectron').Application;
  10. let appPath = path.resolve(__dirname, '../app');
  11. let electronPath = path.resolve(__dirname, '../node_modules/.bin/electron');
  12. test.beforeEach(async t => {
  13. t.context.app = new Application({
  14. path: electronPath,
  15. args: [appPath]
  16. });
  17. await t.context.app.start();
  18. });
  19. test.afterEach(async t => {
  20. await t.context.app.stop();
  21. });
  22. test('basic', async t => {
  23. let app = t.context.app;
  24. await app.client.waitUntilWindowLoaded();
  25. const win = app.browserWindow;
  26. t.is(await app.client.getWindowCount(), 1);
  27. t.is(await app.client.getTitle(), 'SwitchHosts!');
  28. t.false(await win.isMinimized());
  29. t.false(await win.isDevToolsOpened());
  30. t.true(await win.isVisible());
  31. const {width, height} = await win.getBounds();
  32. t.true(width > 0);
  33. t.true(height > 0);
  34. });