diff --git a/pwnyaa/index.test.ts b/pwnyaa/index.test.ts index b274c9bd..c26a3d2a 100644 --- a/pwnyaa/index.test.ts +++ b/pwnyaa/index.test.ts @@ -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'; @@ -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'); @@ -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'; @@ -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 @@ -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(); diff --git a/pwnyaa/index.ts b/pwnyaa/index.ts index aaa98261..6f1ea80c 100644 --- a/pwnyaa/index.ts +++ b/pwnyaa/index.ts @@ -997,5 +997,5 @@ export default async ({eventClient, webClient: slack}: SlackInterface) => { }); // init - updateAll(); + await updateAll(); };