Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Commit 04ebc27

Browse files
authored
Merge pull request #88 from BuffettCode/development
Releave v15
2 parents 7eeba9d + 328edf2 commit 04ebc27

73 files changed

Lines changed: 353 additions & 3185 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package-lock.json

Lines changed: 85 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/__mocks__/api/v2/client.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/__mocks__/api/v2/indicator-property.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/__mocks__/api/v2/quarter-property.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/__mocks__/api/v3/client.ts

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import { HTTPResnpose } from '~/__mocks__/api/v3/http-response'
12
import { default as company } from '~/__mocks__/fixtures/v3/company.js'
23
import { default as daily } from '~/__mocks__/fixtures/v3/daily.js'
34
import { default as quarter } from '~/__mocks__/fixtures/v3/quarter.js'
5+
import { HttpError } from '~/api/http-error'
46
import { Daily } from '~/entities/v3/daily'
57
import { Quarter } from '~/entities/v3/quarter'
68

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

18-
company(): object {
20+
company(ticker: string): object {
21+
if (ticker !== '2371') {
22+
const res = new HTTPResnpose()
23+
throw new HttpError('/v3/company', res)
24+
}
25+
1926
return this.mockCompany()['data']
2027
}
2128

22-
quarter(): Quarter {
29+
quarter(ticker: string): Quarter {
30+
if (ticker !== '2371') {
31+
const res = new HTTPResnpose()
32+
throw new HttpError('/v3/company', res)
33+
}
34+
2335
return Quarter.fromResponse(this.mockQuarter())
2436
}
2537

26-
daily(): Daily {
38+
daily(ticker: string): Daily {
39+
if (ticker !== '2371') {
40+
const res = new HTTPResnpose()
41+
throw new HttpError('/v3/company', res)
42+
}
43+
2744
return Daily.fromResponse(this.mockDaily())
2845
}
2946

30-
ondemandDaily(): Daily {
47+
ondemandDaily(ticker: string): Daily {
48+
if (ticker !== '2371') {
49+
const res = new HTTPResnpose()
50+
throw new HttpError('/v3/company', res)
51+
}
52+
3153
return Daily.fromResponse(this.mockDaily())
3254
}
3355

34-
ondemandQuarter(): Quarter {
56+
ondemandQuarter(ticker: string): Quarter {
57+
if (ticker !== '2371') {
58+
const res = new HTTPResnpose()
59+
throw new HttpError('/v3/company', res)
60+
}
61+
3562
return Quarter.fromResponse(this.mockQuarter())
3663
}
3764
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// GoogleAppsScript.URL_Fetch.HTTPResponseと同じI/F
2+
export class HTTPResnpose {
3+
getResponseCode(): number {
4+
return 404
5+
}
6+
7+
getContent(): number[] {
8+
const text = this.getContentText()
9+
const content = []
10+
11+
for (let i = 0; i < text.length; i++) {
12+
content.push(text.charCodeAt(i))
13+
}
14+
15+
return content
16+
}
17+
18+
getContentText(): string {
19+
return 'NOT FOUND'
20+
}
21+
22+
getAllHeaders(): object {
23+
return {}
24+
}
25+
26+
getHeaders(): object {
27+
return {}
28+
}
29+
30+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
31+
getAs(contentType: string): GoogleAppsScript.Base.Blob {
32+
return null
33+
}
34+
35+
getBlob(): GoogleAppsScript.Base.Blob {
36+
return null
37+
}
38+
}

0 commit comments

Comments
 (0)