Skip to content

Commit dc054aa

Browse files
committed
add another test for new updated mod
I hope this mod keeps updating
1 parent 13ec4d4 commit dc054aa

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,18 @@ class SteamWorkshopScraper {
162162
var time;
163163
let time1 = DateTime.fromFormat(string, "d MMM, yyyy @ h:ma", { locale: 'en', zone: steamDefaultTimezone });
164164
let time2 = DateTime.fromFormat(string, "d MMM @ h:ma", { locale: 'en', zone: steamDefaultTimezone });
165-
let time3 = DateTime.fromFormat(string, "MMM d, @ h:ma", { locale: 'en', zone: steamDefaultTimezone }); // github workflow gets this format
165+
let time3 = DateTime.fromFormat(string, "MMM d, yyyy @ h:ma", { locale: 'en', zone: steamDefaultTimezone }); // github workflow format
166+
let time4 = DateTime.fromFormat(string, "MMM d @ h:ma", { locale: 'en', zone: steamDefaultTimezone }); // github workflow format for current year
166167
if(time1.isValid){
167168
time = time1;
168169
} else if(time2.isValid){
169170
time = time2;
170171
} else if(time3.isValid){
171-
time = time3
172+
time = time3;
173+
} else if(time4.isValid){
174+
time = time4;
172175
} else {
173-
throw new Error('No time format was found in parser for:' + string);
176+
throw new Error('No time format was found in parser for: ' + string);
174177
}
175178
time = time.setZone(Settings.defaultZone);
176179
return time.toString(true);

test/test.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const SteamWorkshopScraper = require('../index.js');
22
const sws = new SteamWorkshopScraper('Universal');
33
var assert = require('assert');
4-
4+
const { DateTime } = require("luxon");
55

66
describe('SteamWorkshopScraper', function () {
77
it('should show 18 entries', async function () {
@@ -54,15 +54,13 @@ describe('SteamWorkshopScraper', function () {
5454

5555
it('GetChangeLog check text and timePosted', async function () {
5656
await sws.GetChangeLog(478528785).then(function (data) { // very old mod
57-
// console.log('data', data.data[0].text);
5857
assert.equal(data.data[0].text, 'Version 1.0');
5958
assert.equal(data.data[0].timePosted, '2015-07-09T21:59:00.000+00:00');
6059
});
6160
});
6261

6362
it('GetInfo never updated mod', async function () {
6463
await sws.GetInfo(518030553).then(function (data) {
65-
// console.log(data);
6664
assert.equal(data.title, 'TXM: Turret Expansion Mod');
6765
assert.equal(data.size, '0.036 MB');
6866
assert.equal(data.timePublished, '2015-09-14T01:52:00.000+00:00');
@@ -71,10 +69,19 @@ describe('SteamWorkshopScraper', function () {
7169
});
7270
});
7371

72+
it('GetInfo active updated mod', async function () {
73+
await sws.GetInfo(731604991).then(function (data) {
74+
assert.equal(data.title, 'Structures Plus (S+)');
75+
assert.equal(data.size, '58.174 MB');
76+
assert.equal(data.timePublished, '2016-07-26T02:40:00.000+00:00');
77+
assert.equal(data.timeUpdated.includes(DateTime.now().year), true);
78+
assert.equal(data.image, 'https://steamuserimages-a.akamaihd.net/ugc/1020574589494908839/7C3E05B2D3568E166D1E9B0A7597782934F2A153/?imw=268&imh=268&ima=fit&impolicy=Letterbox&imcolor=%23000000&letterbox=true');
79+
});
80+
});
81+
7482
it('Timezone', async function () {
7583
const swsTZ = new SteamWorkshopScraper('Europe/Vienna');
7684
await swsTZ.GetInfo(518030553).then(function (data) {
77-
// console.log(data);
7885
assert.equal(data.title, 'TXM: Turret Expansion Mod');
7986
assert.equal(data.size, '0.036 MB');
8087
assert.equal(data.timePublished, '2015-09-14T03:52:00.000+02:00');

0 commit comments

Comments
 (0)