Skip to content

Commit

Permalink
Merge pull request #13 from code-yeongyu/remove-legacy
Browse files Browse the repository at this point in the history
사용하지 않는 메소드들을 삭제합니다.
  • Loading branch information
code-yeongyu authored Feb 10, 2022
2 parents 99f4a3e + 6248269 commit 38fc8e1
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 880 deletions.
7 changes: 0 additions & 7 deletions src/app/naver/elementParser.test.ts

This file was deleted.

15 changes: 0 additions & 15 deletions src/app/naver/elementParser.ts

This file was deleted.

6 changes: 2 additions & 4 deletions src/app/naver/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import Module from "./module";
import { NaverModule } from "./module";
import ModuleFactory from "./moduleFactory";
import URLChanger from "./urlChanger";
import PageInteractor, { LoginEvent, CaptchaStatus } from "./pageInteractor";
import ElementParser from "./elementParser";
import Service from "./service";
import { NaverScraper } from "./scraper";
import { NaverParser } from "./parser";

export {
Module,
NaverModule,
ModuleFactory,
URLChanger,
PageInteractor,
ElementParser,
Service,
LoginEvent,
CaptchaStatus,
Expand Down
12 changes: 2 additions & 10 deletions src/app/naver/module.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
import {
URLChanger,
PageInteractor,
ElementParser,
NaverScraper,
NaverParser,
} from ".";
import { Module as BaseModule } from "../common";
import { URLChanger, PageInteractor, NaverScraper, NaverParser } from ".";

export default interface Module extends BaseModule {
export default interface Module {
readonly urlChanger: URLChanger;
readonly pageInteractor: PageInteractor;
readonly elementParser: ElementParser;
readonly scraper: NaverScraper;
readonly parser: NaverParser;
}
5 changes: 1 addition & 4 deletions src/app/naver/moduleFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import puppeteer from "puppeteer";
import {
Module,
URLChanger,
ElementParser,
PageInteractor,
NaverScraper,
NaverParser,
Expand All @@ -11,15 +10,13 @@ import {
export default class ModuleFactory {
static create(page: puppeteer.Page): Module {
const urlChanger = new URLChanger(page);
const elementParser = new ElementParser(page);
const pageInteractor = new PageInteractor(page, elementParser);
const pageInteractor = new PageInteractor(page);
const scraper = new NaverScraper();
const parser = new NaverParser();

return {
urlChanger,
pageInteractor,
elementParser,
scraper,
parser,
};
Expand Down
799 changes: 0 additions & 799 deletions src/app/naver/pageInteractor.test.ts

This file was deleted.

8 changes: 1 addition & 7 deletions src/app/naver/pageInteractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@ export interface CaptchaStatus {
}

export default class PageInteractor {
private _fullyLoaded = false;

constructor(
private readonly page: puppeteer.Page,
private readonly elementParser: ElementParser
) {
constructor(private readonly page: puppeteer.Page) {
this.page = page;
this.elementParser = elementParser;
}

private async clickLoginButton() {
Expand Down
36 changes: 11 additions & 25 deletions src/app/naver/urlChanger.test.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
import URLChanger from "./urlChanger";

describe("Login", () => {
it("Should move page to login", async () => {
// given
const urlChanger = new URLChanger(page);
const pageSpy = jest.spyOn(page, "goto");
describe("URLChanger", () => {
describe("moveToLoginURL", () => {
it("Should move page to login", async () => {
// given
const urlChanger = new URLChanger(page);
const pageSpy = jest.spyOn(page, "goto");

// when
await urlChanger.moveToLoginURL();
// when
await urlChanger.moveToLoginURL();

// then
expect(pageSpy).toHaveBeenCalledWith(urlChanger.loginURL);
});
});

describe("PaymentHistory", () => {
it("Should move page to payment history", async () => {
// given
const urlChanger = new URLChanger(page);
const pageSpy = jest.spyOn(page, "goto");
const waitForSelectorSpy = jest.spyOn(page, "waitForSelector");
waitForSelectorSpy.mockImplementation(() => Promise.resolve(null));

// when
await urlChanger.moveToPaymentHistoryURL();

// then
expect(pageSpy).toHaveBeenCalledWith(urlChanger.paymentHistoryURL);
// then
expect(pageSpy).toHaveBeenCalledWith(urlChanger.loginURL);
});
});
});
10 changes: 1 addition & 9 deletions src/app/naver/urlChanger.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
import puppeteer from "puppeteer";

export default class URLChanger {
loginURL = "https://nid.naver.com/nidlogin.login";
paymentHistoryURL =
"https://new-m.pay.naver.com/historybenefit/paymenthistory";

constructor(private readonly page: puppeteer.Page) {
this.page = page;
}

loginURL = "https://nid.naver.com/nidlogin.login";
async moveToLoginURL() {
await this.page.goto(this.loginURL);
}

async moveToPaymentHistoryURL() {
await this.page.goto(this.paymentHistoryURL);
await this.page.waitForSelector("div[class^='paymentHistory_section__']");
}
}

0 comments on commit 38fc8e1

Please sign in to comment.