Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 85 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 0 additions & 35 deletions src/__mocks__/api/v2/client.ts

This file was deleted.

33 changes: 0 additions & 33 deletions src/__mocks__/api/v2/indicator-property.ts

This file was deleted.

33 changes: 0 additions & 33 deletions src/__mocks__/api/v2/quarter-property.ts

This file was deleted.

37 changes: 32 additions & 5 deletions src/__mocks__/api/v3/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { HTTPResnpose } from '~/__mocks__/api/v3/http-response'
import { default as company } from '~/__mocks__/fixtures/v3/company.js'
import { default as daily } from '~/__mocks__/fixtures/v3/daily.js'
import { default as quarter } from '~/__mocks__/fixtures/v3/quarter.js'
import { HttpError } from '~/api/http-error'
import { Daily } from '~/entities/v3/daily'
import { Quarter } from '~/entities/v3/quarter'

Expand All @@ -15,23 +17,48 @@ export class BuffettCodeApiClientV3 {
this.mockQuarter.mockReturnValue(quarter)
}

company(): object {
company(ticker: string): object {
if (ticker !== '2371') {
const res = new HTTPResnpose()
throw new HttpError('/v3/company', res)
}

return this.mockCompany()['data']
}

quarter(): Quarter {
quarter(ticker: string): Quarter {
if (ticker !== '2371') {
const res = new HTTPResnpose()
throw new HttpError('/v3/company', res)
}

return Quarter.fromResponse(this.mockQuarter())
}

daily(): Daily {
daily(ticker: string): Daily {
if (ticker !== '2371') {
const res = new HTTPResnpose()
throw new HttpError('/v3/company', res)
}

return Daily.fromResponse(this.mockDaily())
}

ondemandDaily(): Daily {
ondemandDaily(ticker: string): Daily {
if (ticker !== '2371') {
const res = new HTTPResnpose()
throw new HttpError('/v3/company', res)
}

return Daily.fromResponse(this.mockDaily())
}

ondemandQuarter(): Quarter {
ondemandQuarter(ticker: string): Quarter {
if (ticker !== '2371') {
const res = new HTTPResnpose()
throw new HttpError('/v3/company', res)
}

return Quarter.fromResponse(this.mockQuarter())
}
}
38 changes: 38 additions & 0 deletions src/__mocks__/api/v3/http-response.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// GoogleAppsScript.URL_Fetch.HTTPResponseと同じI/F
export class HTTPResnpose {
getResponseCode(): number {
return 404
}

getContent(): number[] {
const text = this.getContentText()
const content = []

for (let i = 0; i < text.length; i++) {
content.push(text.charCodeAt(i))
}

return content
}

getContentText(): string {
return 'NOT FOUND'
}

getAllHeaders(): object {
return {}
}

getHeaders(): object {
return {}
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
getAs(contentType: string): GoogleAppsScript.Base.Blob {
return null
}

getBlob(): GoogleAppsScript.Base.Blob {
return null
}
}
Loading