-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
5 changed files
with
161 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,6 @@ module.exports = { | |
roots: [ | ||
"<rootDir>\\tests" | ||
], | ||
|
||
setupFilesAfterEnv: ["./tests/JestSetupEachTest.js"], | ||
}; |
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
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,84 @@ | ||
const crypto = require("crypto"); | ||
const fs = require("node:fs"); | ||
|
||
|
||
global.Neptune.setupConfigurations(); | ||
|
||
const Client = require("../src/Classes/Client"); | ||
const IPAddress = require("../src/Classes/IPAddress"); | ||
const ClientManager = require('../src/Classes/ClientManager.js'); | ||
|
||
|
||
|
||
/** @type {ClientManager} */ | ||
global.Neptune.clientManager = new ClientManager(global.Neptune.configurationManager); | ||
|
||
|
||
|
||
function getClientSettings(value) { | ||
return { | ||
fileSharingSettings: { | ||
allowClientToDownload: value, | ||
allowClientToUpload: value, | ||
enabled: value, | ||
notifyOnClientUpload: value, | ||
requireConfirmationOnClinetUploads: value, | ||
}, | ||
clipboardSettingsAllFalse: { | ||
allowClientToGet: value, | ||
allowClientToSet: value, | ||
enabled: value, | ||
synchronizeClipboardToClient: value, | ||
}, | ||
notificationSettings: { | ||
enabled: value, | ||
} | ||
} | ||
} | ||
|
||
describe("Client class (non-API) tests", () => { | ||
|
||
var clientUUID = null; | ||
var client = null; | ||
|
||
beforeAll(() => { | ||
let MainWindow = new (require('../src/Windows/mainWindow.js'))(); | ||
clientUUID = crypto.randomUUID(); | ||
client = new Client(global.Neptune.configurationManager, clientUUID); | ||
}); | ||
|
||
afterAll((done) => { | ||
if (client) { | ||
try { | ||
client.delete(); | ||
|
||
setTimeout(() => { | ||
done(); | ||
}, 1000); | ||
} catch { | ||
done(); | ||
} | ||
} else { | ||
done(); | ||
} | ||
}); | ||
|
||
test("Enable clickboard sharing updates buttons", async () => { | ||
|
||
}); | ||
|
||
/*test("emits delete on delete", () => { | ||
client = new Client(global.Neptune.configurationManager, clientUUID); | ||
jest.useFakeTimers(); | ||
const eventSpy = jest.fn(); | ||
client.eventEmitter.on('deleted', eventSpy); | ||
client.delete(); | ||
jest.advanceTimersByTime(1000); | ||
// Expect the event to have been emitted | ||
expect(eventSpy).toHaveBeenCalledTimes(1); | ||
jest.useRealTimers(); | ||
});*/ | ||
}); |
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,59 @@ | ||
/* | ||
* Example Jest unit test file (for NodeGUI windows) | ||
* | ||
* | ||
* A smart thing would to load the window as a constant or variable under NeptuneWindow, this way you're not constantly opening the window over and over. | ||
* | ||
*/ | ||
|
||
global.Neptune.setupConfigurations(); | ||
|
||
test('Open About Close About Window Test', async () => { | ||
// Brings up the about window, clicks the "close" button and confirms it is closed | ||
let aboutPage = new (require('../src/Windows/aboutWindow.js'))(); | ||
aboutPage.show(); | ||
expect(aboutPage.isVisible()).toBe(true); | ||
|
||
aboutPage.getWidget("btnClose").click(); | ||
expect(aboutPage.isVisible()).toBe(false); | ||
}); | ||
|
||
test('Open Connect Close Connect Window test', async () => { | ||
// Brings up the about window, clicks the "close" button and confirms it is closed | ||
let connectWindow = new (require('../src/Windows/tempConnectWindow.js'))(); | ||
connectWindow.show(); | ||
expect(connectWindow.isVisible()).toBe(true); | ||
|
||
connectWindow.getWidget("closeButton").click(); | ||
expect(connectWindow.isVisible()).toBe(false); | ||
}); | ||
|
||
|
||
test('Open Preference Close Preference Window test', async () => { | ||
// Brings up the about window, clicks the "close" button and confirms it is closed | ||
let preferenceWindow = new (require('../src/Windows/preferencePage.js'))(); | ||
preferenceWindow.show(); | ||
expect(preferenceWindow.isVisible()).toBe(true); | ||
|
||
preferenceWindow.getWidget("btnClose").click(); | ||
expect(preferenceWindow.isVisible()).toBe(false); | ||
}); | ||
|
||
async function Shutdown(shutdownTimeout) { | ||
if (typeof shutdownTimeout !== "number") { | ||
shutdownTimeout = 1500; | ||
} | ||
|
||
global.shuttingDown = true; // For when we kill the logger | ||
Neptune.events.application.emit('shutdown', shutdownTimeout) | ||
} | ||
process.Shutdown = Shutdown; | ||
|
||
/*test('Test Shutdown', async () => { | ||
const eventSpy = jest.fn(); | ||
Neptune.events.application.on('shutdown', eventSpy) | ||
expect(eventSpy).toHaveBeenCalledTimes(1); | ||
});*/ | ||
|
||
global.Neptune.tearDownConfigurations(); |