This repository has been archived by the owner on May 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Peter Boothroyd
committed
Sep 6, 2017
1 parent
1a1d33c
commit 5125cf6
Showing
7 changed files
with
259 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,133 @@ | ||
// import * as electronPath from "electron"; | ||
// import * as path from "path"; | ||
/* tslint:disable:no-console */ | ||
import * as path from 'path'; | ||
|
||
// const { Application } = require("spectron"); // tslint:disable-line | ||
import { Application } from 'spectron'; | ||
|
||
// const delay = (time: number) => new Promise((resolve) => setTimeout(resolve, time)); | ||
|
||
// describe("main window", function spec() { | ||
// let app: any; | ||
// beforeAll(async () => { | ||
// app = new Application({ | ||
// path: electronPath, | ||
// args: [path.join(__dirname, "..", "..", "app")], | ||
// }); | ||
// return app.start(); | ||
// }); | ||
|
||
// afterAll(() => { | ||
// if (app && app.isRunning()) { | ||
// return app.stop(); | ||
// } | ||
// }); | ||
|
||
// const findCounter = () => app.client.element("[data-tid='counter']"); | ||
|
||
// const findButtons = async () => { | ||
// const { value } = await app.client.elements("[data-tclass='btn']"); | ||
// return value.map((btn: any) => btn.ELEMENT); | ||
// }; | ||
|
||
// it("should open window", async () => { | ||
// const { client, browserWindow } = app; | ||
|
||
// await client.waitUntilWindowLoaded(); | ||
// await delay(500); | ||
// const title = await browserWindow.getTitle(); | ||
// expect(title).toBe("Dragoman"); | ||
// }); | ||
|
||
// it("should navigate to Counter by "to Counter" link", async () => { | ||
// const { client } = app; | ||
|
||
// await client.click("[data-tid="container"] > a"); | ||
// await delay(100); | ||
// expect(await findCounter().getText()).toBe("0"); | ||
// }); | ||
|
||
// it("should display updated count after increment button click", async () => { | ||
// const { client } = app; | ||
|
||
// const buttons = await findButtons(); | ||
// await client.elementIdClick(buttons[0]); // + | ||
// expect(await findCounter().getText()).toBe("1"); | ||
// }); | ||
|
||
// it("should display updated count after descrement button click", async () => { | ||
// const { client } = app; | ||
|
||
// const buttons = await findButtons(); | ||
// await client.elementIdClick(buttons[1]); // - | ||
// expect(await findCounter().getText()).toBe("0"); | ||
// }); | ||
|
||
// it("shouldn\"t change if even and if odd button clicked", async () => { | ||
// const { client } = app; | ||
|
||
// const buttons = await findButtons(); | ||
// await client.elementIdClick(buttons[2]); // odd | ||
// expect(await findCounter().getText()).toBe("0"); | ||
// }); | ||
|
||
// it("should change if odd and if odd button clicked", async () => { | ||
// const { client } = app; | ||
|
||
// const buttons = await findButtons(); | ||
// await client.elementIdClick(buttons[0]); // + | ||
// await client.elementIdClick(buttons[2]); // odd | ||
// expect(await findCounter().getText()).toBe("2"); | ||
// }); | ||
|
||
// it("should change if async button clicked and a second later", async () => { | ||
// const { client } = app; | ||
|
||
// const buttons = await findButtons(); | ||
// await client.elementIdClick(buttons[3]); // async | ||
// expect(await findCounter().getText()).toBe("2"); | ||
// await delay(1000); | ||
// expect(await findCounter().getText()).toBe("3"); | ||
// }); | ||
|
||
// it("should navigate to home using back button", async () => { | ||
// const { client } = app; | ||
// await client.element( | ||
// "[data-tid="backButton"] > a" | ||
// ).click(); | ||
// await delay(100); | ||
|
||
// expect( | ||
// await client.isExisting("[data-tid="container"]") | ||
// ).toBe(true); | ||
// }); | ||
// }); | ||
describe('main window', function spec() { | ||
let app: Application; | ||
beforeAll(() => { | ||
let pathToBinary; | ||
|
||
switch (process.platform) { | ||
case 'linux': | ||
pathToBinary = path.join(__dirname, '../../release/linux-unpacked/dragoman'); | ||
break; | ||
|
||
case 'darwin': | ||
pathToBinary = path.join(__dirname, '../../release/mac/Dragoman.app/Contents/MacOS/Dragoman'); | ||
break; | ||
|
||
case 'win32': | ||
pathToBinary = path.join(__dirname, '../release/win-unpacked/Dragoman.exe'); | ||
break; | ||
|
||
default: | ||
throw new Error('Path to the built binary needs to be defined for this platform in test/index.js'); | ||
} | ||
|
||
app = new Application({ | ||
path: pathToBinary, | ||
}); | ||
return app.start(); | ||
}); | ||
|
||
afterAll(() => { | ||
if (app && app.isRunning()) { | ||
return app.stop(); | ||
} else { | ||
return; | ||
} | ||
}); | ||
|
||
// const findCounter = () => app.client.element('[data-tid='counter']'); | ||
|
||
// const findButtons = async () => { | ||
// const { value } = await app.client.elements('[data-tclass='btn']'); | ||
// return value.map((btn: any) => btn.ELEMENT); | ||
// }; | ||
|
||
it('should open window', () => { | ||
// delay(1000); | ||
const { client, browserWindow } = app; | ||
|
||
return client.waitUntilWindowLoaded() | ||
.then(() => { return browserWindow.webContents.isDevToolsOpened(); }) | ||
.then((isDevToolsOpen) => { | ||
expect(isDevToolsOpen).toBe(false); | ||
}); | ||
}); | ||
|
||
it('should have a title', async () => { | ||
const { client, browserWindow } = app; | ||
|
||
await client.waitUntilWindowLoaded(); | ||
const title = await browserWindow.getTitle(); | ||
console.error(title); | ||
expect(title).toBe('Dragoman'); | ||
}); | ||
|
||
// it('should navigate to Counter by 'to Counter' link', async () => { | ||
// const { client } = app; | ||
|
||
// await client.click('[data-tid='container'] > a'); | ||
// await delay(100); | ||
// expect(await findCounter().getText()).toBe('0'); | ||
// }); | ||
|
||
// it('should display updated count after increment button click', async () => { | ||
// const { client } = app; | ||
|
||
// const buttons = await findButtons(); | ||
// await client.elementIdClick(buttons[0]); // + | ||
// expect(await findCounter().getText()).toBe('1'); | ||
// }); | ||
|
||
// it('should display updated count after descrement button click', async () => { | ||
// const { client } = app; | ||
|
||
// const buttons = await findButtons(); | ||
// await client.elementIdClick(buttons[1]); // - | ||
// expect(await findCounter().getText()).toBe('0'); | ||
// }); | ||
|
||
// it('shouldn\'t change if even and if odd button clicked', async () => { | ||
// const { client } = app; | ||
|
||
// const buttons = await findButtons(); | ||
// await client.elementIdClick(buttons[2]); // odd | ||
// expect(await findCounter().getText()).toBe('0'); | ||
// }); | ||
|
||
// it('should change if odd and if odd button clicked', async () => { | ||
// const { client } = app; | ||
|
||
// const buttons = await findButtons(); | ||
// await client.elementIdClick(buttons[0]); // + | ||
// await client.elementIdClick(buttons[2]); // odd | ||
// expect(await findCounter().getText()).toBe('2'); | ||
// }); | ||
|
||
// it('should change if async button clicked and a second later', async () => { | ||
// const { client } = app; | ||
|
||
// const buttons = await findButtons(); | ||
// await client.elementIdClick(buttons[3]); // async | ||
// expect(await findCounter().getText()).toBe('2'); | ||
// await delay(1000); | ||
// expect(await findCounter().getText()).toBe('3'); | ||
// }); | ||
|
||
// it('should navigate to home using back button', async () => { | ||
// const { client } = app; | ||
// await client.element( | ||
// '[data-tid='backButton'] > a' | ||
// ).click(); | ||
// await delay(100); | ||
|
||
// expect( | ||
// await client.isExisting('[data-tid='container']') | ||
// ).toBe(true); | ||
// }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import settingsData, { initialSettingsDataState } from '../../app/reducers/settingsData'; | ||
import * as settingsDataActions from '../../app/actions/settingsData'; | ||
|
||
describe('settings UI reducer', () => { | ||
describe('endpoint error', () => { | ||
it('should handle initial state', () => { | ||
expect(settingsData(undefined, { type: 'UNKNOWN', payload: {} })).toEqual(initialSettingsDataState); | ||
}); | ||
|
||
it('should handle SET_PROTO_DISCOVERY_ROOT', () => { | ||
expect(settingsData(undefined, settingsDataActions.setProtoDiscoveryRoot('/Users')).protoDiscoveryRoot).toEqual('/Users'); | ||
}); | ||
|
||
it('should handle SET_ENDPOINT', () => { | ||
expect(settingsData(undefined, settingsDataActions.setEndpoint('host:50')).endpoint).toEqual('host:50'); | ||
}); | ||
|
||
it('should handle SET_CONFIG_SET_PATH_ERROR', () => { | ||
expect(settingsData(undefined, settingsDataActions.setConfigSetPath('/Users')).configSetPath).toEqual('/Users'); | ||
}); | ||
|
||
it('should handle SET_CONFIG_NAME', () => { | ||
expect(settingsData(undefined, settingsDataActions.setConfigName('staging')).configName).toEqual('staging'); | ||
}); | ||
|
||
it('should handle SET_DEADLINE_MS', () => { | ||
expect(settingsData(undefined, settingsDataActions.setDeadlineMs(50)).deadlineMs).toEqual(50); | ||
}); | ||
|
||
it('should handle SET_ADD_PROTOC_INCLUDES', () => { | ||
expect(settingsData(undefined, settingsDataActions.setAddProtocIncludes('/Users,/Users/peteboothroyd')).addProtocIncludes).toEqual('/Users,/Users/peteboothroyd'); | ||
}); | ||
|
||
it('should handle SET_OAUTH_REFRESH_TOKEN_ENDPOINT_URL', () => { | ||
expect(settingsData(undefined, settingsDataActions.setOauthRefreshTokenEndpointUrl('https://improbable.io')).oauthRefreshTokenEndpointUrl).toEqual('https://improbable.io'); | ||
}); | ||
|
||
it('should handle SET_OAUTH_CLIENT_ID', () => { | ||
expect(settingsData(undefined, settingsDataActions.setOauthClientId('id')).oauthClientId).toEqual('id'); | ||
}); | ||
|
||
it('should handle SET_OAUTH_CLIENT_SECRET', () => { | ||
expect(settingsData(undefined, settingsDataActions.setOauthClientSecret('secret')).oauthClientSecret).toEqual('secret'); | ||
}); | ||
|
||
it('should handle SET_OAUTH_REFRESH_TOKEN_PATH', () => { | ||
expect(settingsData(undefined, settingsDataActions.setOauthRefreshTokenPath('/Users')).oauthRefreshTokenPath).toEqual('/Users'); | ||
}); | ||
|
||
it('should handle SET_OAUTH_ACCESS_TOKEN_PATH', () => { | ||
expect(settingsData(undefined, settingsDataActions.setOauthAccessTokenPath('/Users')).oauthAccessTokenPath).toEqual('/Users'); | ||
}); | ||
|
||
it('should handle SET_USE_TLS', () => { | ||
expect(settingsData(undefined, settingsDataActions.setUseTls(true)).useTls).toEqual(true); | ||
}); | ||
|
||
it('should handle SET_TLS_CA_CERT_PATH', () => { | ||
expect(settingsData(undefined, settingsDataActions.setTlsCaCertPath('/Users')).tlsCaCertPath).toEqual('/Users'); | ||
}); | ||
|
||
it('should handle SET_TLS_CLIENT_KEY_PATH', () => { | ||
expect(settingsData(undefined, settingsDataActions.setTlsClientKeyPath('/Users')).tlsClientKeyPath).toEqual('/Users'); | ||
}); | ||
|
||
it('should handle SET_TLS_CLIENT_CERT_PATH', () => { | ||
expect(settingsData(undefined, settingsDataActions.setTlsClientCertPath('/Users')).tlsClientCertPath).toEqual('/Users'); | ||
}); | ||
|
||
it('should handle SET_TLS_CLIENT_OVERRRIDE_AUTHORITY', () => { | ||
expect(settingsData(undefined, settingsDataActions.setTlsClientOverrideAuthority('authority')).tlsClientOverrideAuthority).toEqual('authority'); | ||
}); | ||
|
||
// TODO: Add tests for importing polyglot configs from an example config file | ||
}); | ||
}); |
Oops, something went wrong.