Changed version check

pull/11/head
MillenniumEarl 2020-10-10 11:33:54 +02:00
parent 5275c82448
commit 44d7e126c8
2 changed files with 10 additions and 12 deletions

View File

@ -181,22 +181,20 @@ module.exports.loadF95BaseData = async function () {
};
/**
* @public
* Returns the currently online version of the specified game.
* Chek if exists a new version of the game.
* You **must** be logged in to the portal before calling this method.
* @param {GameInfo} info Information about the game to get the version for
* @returns {Promise<String>} Currently online version of the specified game
* @returns {Promise<Boolean>} true if an update is available, false otherwise
*/
module.exports.getGameVersion = async function (info) {
module.exports.chekIfGameHasUpdate = async function (info) {
if (!shared.isLogged) {
console.warn("user not authenticated, unable to continue");
return info.version;
}
let exists = await urlExists(info.f95url, true);
// F95 change URL at every game update, so if the URL is the same no update is available
if (exists) return info.version;
else return (await module.exports.getGameData(info.name, info.isMod)).version;
// F95 change URL at every game update,
// so if the URL is the same no update is available
return await urlExists(info.f95url, true);
};
/**
* @public

View File

@ -159,12 +159,12 @@ describe("Load user data", function () {
});
});
describe("Check game version", function () {
describe("Check game update", function () {
//#region Set-up
this.timeout(30000); // All tests in this suite get 30 seconds before timeout
//#endregion Set-up
it("Get game version", async function () {
it("Get game update", async function () {
const loginResult = await F95API.login(USERNAME, PASSWORD);
expect(loginResult.success).to.be.true;
@ -175,7 +175,7 @@ describe("Check game version", function () {
// https://f95zone.to/threads/kingdom-of-deception-v0-10-8-hreinn-games.2733/
const result = (await F95API.getGameData("Kingdom of Deception", false))[0];
let version = await F95API.getGameVersion(result);
expect(version).to.be.equal(result.version);
let update = await F95API.chekIfGameHasUpdate(result);
expect(update).to.be.false;
});
});