Skip to content

Commit

Permalink
Merge pull request #983 from tsg-ut/pwnyaa-test-fix
Browse files Browse the repository at this point in the history
Fix pwnyaa unit test degration from #931
  • Loading branch information
hakatashi authored Feb 11, 2025
2 parents 1e67be1 + fda007f commit fa9978a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions pwnyaa/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import path from 'path';
import Slack from '../lib/slackMock';
import {getMemberName} from '../lib/slackUtils';
import {AchievementType, Challenge, SolvedInfo, Profile} from './lib/BasicTypes';
import {fetchChallsAH, fetchUserProfileAH} from './lib/AHManager';
import {fetchChallsCH, fetchUserProfileCH} from './lib/CHManager';
import {fetchChallsKSN, fetchUserProfileKSN} from './lib/KSNManager';
import {fetchChallsTW, fetchUserProfileTW} from './lib/TWManager';
Expand All @@ -12,6 +13,7 @@ import pwnyaa, {State} from './index';

jest.mock('../achievements');
jest.unmock('axios');
jest.mock('./lib/AHManager');
jest.mock('./lib/CHManager');
jest.mock('./lib/TWManager');
jest.mock('./lib/XYZManager');
Expand Down Expand Up @@ -41,6 +43,11 @@ const sampleChallsKSN: Challenge[] = [
{name: 'ksnChallA', score: 400, id: '1'},
{name: 'ksnChallB', score: 500, id: '2'},
];
// eslint-disable-next-line array-plural/array-plural
const sampleChallsAH: Challenge[] = [
{name: 'ahChallA', score: 400, id: '1'},
{name: 'ahChallB', score: 500, id: '2'},
];

// eslint-disable-next-line no-unused-vars
const NOW = 'August 20, 2020 09:00:00';
Expand Down Expand Up @@ -107,6 +114,16 @@ const sampleProfileKSN: Profile = {
solvedChalls: [sampleSolved1],
};

const sampleProfileAH: Profile = {
username: 'hogeko',
country: 'JP',
rank: '30/1000',
score: '4000',
comment: 'Crazy Winter',
registeredAt: '2020/01/27',
solvedChalls: [sampleSolved1],
};


beforeAll(async () => {
// backup state file
Expand Down Expand Up @@ -155,6 +172,8 @@ beforeEach(async () => {
(fetchUserProfileCH as jest.Mock).mockReturnValue(sampleProfileCH);
(fetchChallsKSN as jest.Mock).mockReturnValue(sampleChallsKSN);
(fetchUserProfileKSN as jest.Mock).mockReturnValue(sampleProfileKSN);
(fetchChallsAH as jest.Mock).mockReturnValue(sampleChallsAH);
(fetchUserProfileAH as jest.Mock).mockReturnValue(sampleProfileAH);
(getMemberName as jest.Mock).mockReturnValue('FakeName');

slack = new Slack();
Expand Down
2 changes: 1 addition & 1 deletion pwnyaa/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -997,5 +997,5 @@ export default async ({eventClient, webClient: slack}: SlackInterface) => {
});

// init
updateAll();
await updateAll();
};

0 comments on commit fa9978a

Please sign in to comment.