@book000/pixivts 0.46.48 → 0.46.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/dist/checks.d.ts +0 -19
- package/dist/checks.d.ts.map +0 -1
- package/dist/checks.js +0 -85
- package/dist/checks.js.map +0 -1
- package/dist/checks.test.d.ts +0 -2
- package/dist/checks.test.d.ts.map +0 -1
- package/dist/checks.test.js +0 -306
- package/dist/checks.test.js.map +0 -1
- package/dist/index.d.ts +0 -30
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -51
- package/dist/index.js.map +0 -1
- package/dist/options.d.ts +0 -248
- package/dist/options.d.ts.map +0 -1
- package/dist/options.js +0 -154
- package/dist/options.js.map +0 -1
- package/dist/options.test.d.ts +0 -2
- package/dist/options.test.d.ts.map +0 -1
- package/dist/options.test.js +0 -117
- package/dist/options.test.js.map +0 -1
- package/dist/pixiv.d.ts +0 -268
- package/dist/pixiv.d.ts.map +0 -1
- package/dist/pixiv.js +0 -698
- package/dist/pixiv.js.map +0 -1
- package/dist/pixiv.test.d.ts +0 -2
- package/dist/pixiv.test.d.ts.map +0 -1
- package/dist/pixiv.test.js +0 -729
- package/dist/pixiv.test.js.map +0 -1
- package/dist/saving-responses/index.d.ts +0 -119
- package/dist/saving-responses/index.d.ts.map +0 -1
- package/dist/saving-responses/index.js +0 -263
- package/dist/saving-responses/index.js.map +0 -1
- package/dist/saving-responses/index.test.d.ts +0 -2
- package/dist/saving-responses/index.test.d.ts.map +0 -1
- package/dist/saving-responses/index.test.js +0 -469
- package/dist/saving-responses/index.test.js.map +0 -1
- package/dist/saving-responses/response-entity.d.ts +0 -16
- package/dist/saving-responses/response-entity.d.ts.map +0 -1
- package/dist/saving-responses/response-entity.js +0 -101
- package/dist/saving-responses/response-entity.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/types/endpoints/v1/illust/bookmark/delete.d.ts +0 -14
- package/dist/types/endpoints/v1/illust/bookmark/delete.d.ts.map +0 -1
- package/dist/types/endpoints/v1/illust/bookmark/delete.js +0 -3
- package/dist/types/endpoints/v1/illust/bookmark/delete.js.map +0 -1
- package/dist/types/endpoints/v1/illust/detail.d.ts +0 -25
- package/dist/types/endpoints/v1/illust/detail.d.ts.map +0 -1
- package/dist/types/endpoints/v1/illust/detail.js +0 -20
- package/dist/types/endpoints/v1/illust/detail.js.map +0 -1
- package/dist/types/endpoints/v1/illust/ranking.d.ts +0 -51
- package/dist/types/endpoints/v1/illust/ranking.d.ts.map +0 -1
- package/dist/types/endpoints/v1/illust/ranking.js +0 -40
- package/dist/types/endpoints/v1/illust/ranking.js.map +0 -1
- package/dist/types/endpoints/v1/illust/recommended.d.ts +0 -85
- package/dist/types/endpoints/v1/illust/recommended.d.ts.map +0 -1
- package/dist/types/endpoints/v1/illust/recommended.js +0 -37
- package/dist/types/endpoints/v1/illust/recommended.js.map +0 -1
- package/dist/types/endpoints/v1/illust/series.d.ts +0 -45
- package/dist/types/endpoints/v1/illust/series.d.ts.map +0 -1
- package/dist/types/endpoints/v1/illust/series.js +0 -31
- package/dist/types/endpoints/v1/illust/series.js.map +0 -1
- package/dist/types/endpoints/v1/illust/ugoira/metadata.d.ts +0 -25
- package/dist/types/endpoints/v1/illust/ugoira/metadata.d.ts.map +0 -1
- package/dist/types/endpoints/v1/illust/ugoira/metadata.js +0 -20
- package/dist/types/endpoints/v1/illust/ugoira/metadata.js.map +0 -1
- package/dist/types/endpoints/v1/manga/recommended.d.ts +0 -72
- package/dist/types/endpoints/v1/manga/recommended.d.ts.map +0 -1
- package/dist/types/endpoints/v1/manga/recommended.js +0 -33
- package/dist/types/endpoints/v1/manga/recommended.js.map +0 -1
- package/dist/types/endpoints/v1/novel/bookmark/delete.d.ts +0 -14
- package/dist/types/endpoints/v1/novel/bookmark/delete.d.ts.map +0 -1
- package/dist/types/endpoints/v1/novel/bookmark/delete.js +0 -3
- package/dist/types/endpoints/v1/novel/bookmark/delete.js.map +0 -1
- package/dist/types/endpoints/v1/novel/ranking.d.ts +0 -47
- package/dist/types/endpoints/v1/novel/ranking.d.ts.map +0 -1
- package/dist/types/endpoints/v1/novel/ranking.js +0 -39
- package/dist/types/endpoints/v1/novel/ranking.js.map +0 -1
- package/dist/types/endpoints/v1/novel/recommended.d.ts +0 -72
- package/dist/types/endpoints/v1/novel/recommended.d.ts.map +0 -1
- package/dist/types/endpoints/v1/novel/recommended.js +0 -32
- package/dist/types/endpoints/v1/novel/recommended.js.map +0 -1
- package/dist/types/endpoints/v1/novel/related.d.ts +0 -37
- package/dist/types/endpoints/v1/novel/related.d.ts.map +0 -1
- package/dist/types/endpoints/v1/novel/related.js +0 -24
- package/dist/types/endpoints/v1/novel/related.js.map +0 -1
- package/dist/types/endpoints/v1/search/illust.d.ts +0 -90
- package/dist/types/endpoints/v1/search/illust.d.ts.map +0 -1
- package/dist/types/endpoints/v1/search/illust.js +0 -35
- package/dist/types/endpoints/v1/search/illust.js.map +0 -1
- package/dist/types/endpoints/v1/search/novel.d.ts +0 -90
- package/dist/types/endpoints/v1/search/novel.d.ts.map +0 -1
- package/dist/types/endpoints/v1/search/novel.js +0 -35
- package/dist/types/endpoints/v1/search/novel.js.map +0 -1
- package/dist/types/endpoints/v1/user/bookmarks/illust.d.ts +0 -48
- package/dist/types/endpoints/v1/user/bookmarks/illust.d.ts.map +0 -1
- package/dist/types/endpoints/v1/user/bookmarks/illust.js +0 -31
- package/dist/types/endpoints/v1/user/bookmarks/illust.js.map +0 -1
- package/dist/types/endpoints/v1/user/bookmarks/novel.d.ts +0 -44
- package/dist/types/endpoints/v1/user/bookmarks/novel.d.ts.map +0 -1
- package/dist/types/endpoints/v1/user/bookmarks/novel.js +0 -28
- package/dist/types/endpoints/v1/user/bookmarks/novel.js.map +0 -1
- package/dist/types/endpoints/v1/user/detail.d.ts +0 -44
- package/dist/types/endpoints/v1/user/detail.d.ts.map +0 -1
- package/dist/types/endpoints/v1/user/detail.js +0 -26
- package/dist/types/endpoints/v1/user/detail.js.map +0 -1
- package/dist/types/endpoints/v2/illust/bookmark/add.d.ts +0 -28
- package/dist/types/endpoints/v2/illust/bookmark/add.d.ts.map +0 -1
- package/dist/types/endpoints/v2/illust/bookmark/add.js +0 -3
- package/dist/types/endpoints/v2/illust/bookmark/add.js.map +0 -1
- package/dist/types/endpoints/v2/illust/related.d.ts +0 -41
- package/dist/types/endpoints/v2/illust/related.d.ts.map +0 -1
- package/dist/types/endpoints/v2/illust/related.js +0 -29
- package/dist/types/endpoints/v2/illust/related.js.map +0 -1
- package/dist/types/endpoints/v2/novel/bookmark/add.d.ts +0 -27
- package/dist/types/endpoints/v2/novel/bookmark/add.d.ts.map +0 -1
- package/dist/types/endpoints/v2/novel/bookmark/add.js +0 -3
- package/dist/types/endpoints/v2/novel/bookmark/add.js.map +0 -1
- package/dist/types/endpoints/v2/novel/detail.d.ts +0 -25
- package/dist/types/endpoints/v2/novel/detail.d.ts.map +0 -1
- package/dist/types/endpoints/v2/novel/detail.js +0 -20
- package/dist/types/endpoints/v2/novel/detail.js.map +0 -1
- package/dist/types/endpoints/v2/novel/series.d.ts +0 -49
- package/dist/types/endpoints/v2/novel/series.d.ts.map +0 -1
- package/dist/types/endpoints/v2/novel/series.js +0 -31
- package/dist/types/endpoints/v2/novel/series.js.map +0 -1
- package/dist/types/endpoints/webview/v2/novel.d.ts +0 -21
- package/dist/types/endpoints/webview/v2/novel.d.ts.map +0 -1
- package/dist/types/endpoints/webview/v2/novel.js +0 -18
- package/dist/types/endpoints/webview/v2/novel.js.map +0 -1
- package/dist/types/error-response.d.ts +0 -29
- package/dist/types/error-response.d.ts.map +0 -1
- package/dist/types/error-response.js +0 -3
- package/dist/types/error-response.js.map +0 -1
- package/dist/types/pixiv-common.d.ts +0 -96
- package/dist/types/pixiv-common.d.ts.map +0 -1
- package/dist/types/pixiv-common.js +0 -66
- package/dist/types/pixiv-common.js.map +0 -1
- package/dist/types/pixiv-illust-series.d.ts +0 -56
- package/dist/types/pixiv-illust-series.d.ts.map +0 -1
- package/dist/types/pixiv-illust-series.js +0 -26
- package/dist/types/pixiv-illust-series.js.map +0 -1
- package/dist/types/pixiv-illust.d.ts +0 -167
- package/dist/types/pixiv-illust.d.ts.map +0 -1
- package/dist/types/pixiv-illust.js +0 -53
- package/dist/types/pixiv-illust.js.map +0 -1
- package/dist/types/pixiv-novel-series.d.ts +0 -84
- package/dist/types/pixiv-novel-series.d.ts.map +0 -1
- package/dist/types/pixiv-novel-series.js +0 -43
- package/dist/types/pixiv-novel-series.js.map +0 -1
- package/dist/types/pixiv-novel.d.ts +0 -122
- package/dist/types/pixiv-novel.d.ts.map +0 -1
- package/dist/types/pixiv-novel.js +0 -42
- package/dist/types/pixiv-novel.js.map +0 -1
- package/dist/types/pixiv-ugoira.d.ts +0 -50
- package/dist/types/pixiv-ugoira.d.ts.map +0 -1
- package/dist/types/pixiv-ugoira.js +0 -34
- package/dist/types/pixiv-ugoira.js.map +0 -1
- package/dist/types/pixiv-user.d.ts +0 -184
- package/dist/types/pixiv-user.d.ts.map +0 -1
- package/dist/types/pixiv-user.js +0 -97
- package/dist/types/pixiv-user.js.map +0 -1
- package/dist/utils.d.ts +0 -3
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -15
- package/dist/utils.js.map +0 -1
- package/dist/utils.test.d.ts +0 -2
- package/dist/utils.test.d.ts.map +0 -1
- package/dist/utils.test.js +0 -15
- package/dist/utils.test.js.map +0 -1
package/dist/pixiv.test.js
DELETED
|
@@ -1,729 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
/* eslint-disable @typescript-eslint/unbound-method */
|
|
7
|
-
const options_1 = require("./options");
|
|
8
|
-
const pixiv_1 = __importDefault(require("./pixiv"));
|
|
9
|
-
const detail_1 = require("./types/endpoints/v1/illust/detail");
|
|
10
|
-
const ranking_1 = require("./types/endpoints/v1/illust/ranking");
|
|
11
|
-
const recommended_1 = require("./types/endpoints/v1/illust/recommended");
|
|
12
|
-
const series_1 = require("./types/endpoints/v1/illust/series");
|
|
13
|
-
const recommended_2 = require("./types/endpoints/v1/manga/recommended");
|
|
14
|
-
const ranking_2 = require("./types/endpoints/v1/novel/ranking");
|
|
15
|
-
const recommended_3 = require("./types/endpoints/v1/novel/recommended");
|
|
16
|
-
const related_1 = require("./types/endpoints/v1/novel/related");
|
|
17
|
-
const illust_1 = require("./types/endpoints/v1/search/illust");
|
|
18
|
-
const novel_1 = require("./types/endpoints/v1/search/novel");
|
|
19
|
-
const illust_2 = require("./types/endpoints/v1/user/bookmarks/illust");
|
|
20
|
-
const novel_2 = require("./types/endpoints/v1/user/bookmarks/novel");
|
|
21
|
-
const detail_2 = require("./types/endpoints/v1/user/detail");
|
|
22
|
-
const related_2 = require("./types/endpoints/v2/illust/related");
|
|
23
|
-
const detail_3 = require("./types/endpoints/v2/novel/detail");
|
|
24
|
-
const series_2 = require("./types/endpoints/v2/novel/series");
|
|
25
|
-
const utils_1 = require("./utils");
|
|
26
|
-
const axios_1 = __importDefault(require("axios"));
|
|
27
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
28
|
-
jest.setTimeout(120000); // 120sec
|
|
29
|
-
describe('pixiv', () => {
|
|
30
|
-
let pixiv;
|
|
31
|
-
beforeAll(async () => {
|
|
32
|
-
// .envファイルから環境変数を読み込む。dotenvなどを使用しない
|
|
33
|
-
if (node_fs_1.default.existsSync('.env')) {
|
|
34
|
-
const env = node_fs_1.default.readFileSync('.env', 'utf8');
|
|
35
|
-
for (const line of env.split('\n')) {
|
|
36
|
-
const [key, value] = line.split('=');
|
|
37
|
-
if (key && value) {
|
|
38
|
-
process.env[key] = value;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const pixivRefreshToken = process.env.PIXIV_REFRESH_TOKEN;
|
|
43
|
-
if (!pixivRefreshToken) {
|
|
44
|
-
throw new Error('PIXIV_REFRESH_TOKEN is not set');
|
|
45
|
-
}
|
|
46
|
-
pixiv = await pixiv_1.default.of(pixivRefreshToken, {
|
|
47
|
-
debugOptions: {
|
|
48
|
-
outputResponse: {
|
|
49
|
-
enable: true,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
afterAll(async () => {
|
|
55
|
-
await pixiv.close();
|
|
56
|
-
});
|
|
57
|
-
it('illustDetail:107565629[illust]', async () => {
|
|
58
|
-
const illustDetail = await pixiv.illustDetail({
|
|
59
|
-
illustId: 107565629,
|
|
60
|
-
});
|
|
61
|
-
expect(illustDetail.status).toBe(200);
|
|
62
|
-
expect(illustDetail.data.illust.id).toBe(107565629);
|
|
63
|
-
expect(illustDetail.data.illust.title).toBe('フブキちゃん衣装着てみたみょ~ん余');
|
|
64
|
-
expect(illustDetail.data.illust.type).toBe('illust');
|
|
65
|
-
// "square_medium": "https://i.pximg.net/c/360x360_70/img-master/img/2023/04/27/13/39/51/107565629_p0_square1200.jpg",
|
|
66
|
-
expect(illustDetail.data.illust.image_urls.square_medium).toMatch(/^https:\/\/i\.pximg\.net\/c\/360x360_70\/img-master\/img\/.+_square1200\.jpg$/);
|
|
67
|
-
// "medium": "https://i.pximg.net/c/540x540_70/img-master/img/2023/04/27/13/39/51/107565629_p0_master1200.jpg",
|
|
68
|
-
expect(illustDetail.data.illust.image_urls.medium).toMatch(/^https:\/\/i\.pximg\.net\/c\/540x540_70\/img-master\/img\/.+_master1200\.jpg$/);
|
|
69
|
-
// "large": "https://i.pximg.net/c/600x1200_90/img-master/img/2023/04/27/13/39/51/107565629_p0_master1200.jpg",
|
|
70
|
-
expect(illustDetail.data.illust.image_urls.large).toMatch(/^https:\/\/i\.pximg\.net\/c\/600x1200_90\/img-master\/img\/.+_master1200\.jpg$/);
|
|
71
|
-
expect(illustDetail.data.illust.caption).toBe('');
|
|
72
|
-
expect(illustDetail.data.illust.restrict).toBe(0);
|
|
73
|
-
expect(illustDetail.data.illust.user.id).toBe(16668308);
|
|
74
|
-
expect(illustDetail.data.illust.user.name).toBe('桜もち');
|
|
75
|
-
expect(illustDetail.data.illust.user.account).toBe('yukitohoshizora');
|
|
76
|
-
// https://i.pximg.net/user-profile/img/
|
|
77
|
-
expect(illustDetail.data.illust.user.profile_image_urls.medium).toMatch(/^https:\/\/i\.pximg\.net\/user-profile\/img\/.+\.png$/);
|
|
78
|
-
expect(illustDetail.data.illust.tags.length).toBeGreaterThan(0);
|
|
79
|
-
expect(illustDetail.data.illust.tools).toBeDefined();
|
|
80
|
-
expect(illustDetail.data.illust.tools.length).toBe(0);
|
|
81
|
-
expect(illustDetail.data.illust.create_date).toBe('2023-04-27T13:39:51+09:00');
|
|
82
|
-
expect(illustDetail.data.illust.page_count).toBe(1);
|
|
83
|
-
expect(illustDetail.data.illust.width).toBe(1728);
|
|
84
|
-
expect(illustDetail.data.illust.height).toBe(2626);
|
|
85
|
-
expect(illustDetail.data.illust.sanity_level).toBe(2);
|
|
86
|
-
expect(illustDetail.data.illust.x_restrict).toBe(0);
|
|
87
|
-
expect(illustDetail.data.illust.series).toBeNull();
|
|
88
|
-
// "original_image_url": "https://i.pximg.net/img-original/img/2023/04/27/13/39/51/107565629_p0.png",
|
|
89
|
-
expect(illustDetail.data.illust.meta_single_page.original_image_url).toMatch(/^https:\/\/i\.pximg\.net\/img-original\/img\/.+_p0\.png$/);
|
|
90
|
-
expect(illustDetail.data.illust.meta_pages).toHaveLength(0);
|
|
91
|
-
expect(illustDetail.data.illust.total_bookmarks).toBeGreaterThan(0);
|
|
92
|
-
expect(illustDetail.data.illust.total_view).toBeGreaterThan(0);
|
|
93
|
-
expect(illustDetail.data.illust.visible).toBe(true);
|
|
94
|
-
expect(illustDetail.data.illust.illust_ai_type).toBe(1);
|
|
95
|
-
expect(illustDetail.data.illust.illust_book_style).toBe(0);
|
|
96
|
-
const check = new detail_1.GetV1IllustDetailCheck();
|
|
97
|
-
expect(() => check.throwIfResponseFailed(illustDetail.data)).not.toThrow();
|
|
98
|
-
expect((0, utils_1.omit)(illustDetail.data.illust, [
|
|
99
|
-
'total_bookmarks',
|
|
100
|
-
'total_comments',
|
|
101
|
-
'total_view',
|
|
102
|
-
])).toMatchSnapshot();
|
|
103
|
-
});
|
|
104
|
-
it('illustDetail:103905962[manga]', async () => {
|
|
105
|
-
const illustDetail = await pixiv.illustDetail({
|
|
106
|
-
illustId: 103905962,
|
|
107
|
-
});
|
|
108
|
-
expect(illustDetail.status).toBe(200);
|
|
109
|
-
expect(illustDetail.data.illust.id).toBe(103905962);
|
|
110
|
-
expect(illustDetail.data.illust.title).toBe('【C101】あくあに恋した猫の話');
|
|
111
|
-
expect(illustDetail.data.illust.type).toBe('manga');
|
|
112
|
-
// "square_medium": "https://i.pximg.net/c/360x360_70/img-master/img/2023/04/27/13/39/51/107565629_p0_square1200.jpg",
|
|
113
|
-
expect(illustDetail.data.illust.image_urls.square_medium).toMatch(/^https:\/\/i\.pximg\.net\/c\/360x360_70\/img-master\/img\/.+_square1200\.jpg$/);
|
|
114
|
-
// "medium": "https://i.pximg.net/c/540x540_70/img-master/img/2023/04/27/13/39/51/107565629_p0_master1200.jpg",
|
|
115
|
-
expect(illustDetail.data.illust.image_urls.medium).toMatch(/^https:\/\/i\.pximg\.net\/c\/540x540_70\/img-master\/img\/.+_master1200\.jpg$/);
|
|
116
|
-
// "large": "https://i.pximg.net/c/600x1200_90/img-master/img/2023/04/27/13/39/51/107565629_p0_master1200.jpg",
|
|
117
|
-
expect(illustDetail.data.illust.image_urls.large).toMatch(/^https:\/\/i\.pximg\.net\/c\/600x1200_90\/img-master\/img\/.+_master1200\.jpg$/);
|
|
118
|
-
expect(illustDetail.data.illust.caption).toBe("C101の新刊サンプルです!<br /><br />恋愛アドベンチャーゲーム『あくありうむ。』に登場する「猫」。<br />彼はどんなことを考えていたのか?<br />彼にとって、これはどんな物語だったのか?<br />そういった本編で語られなかった部分を想像で掘り下げたお話です。<br />※本文は『あくありうむ。』のネタバレおよび多少の負傷描写を含みます。苦手な方はご注意ください。<br /><br />【1日目東C-13b/くらうでぃ】でお待ちしています!<br /><br />メロンブックス様にて新刊の事前予約も始まっています!<br />気になる方は是非チェックしてみてください!<br />【<a href=\"https://www.melonbooks.co.jp/detail/detail.php?product_id=1746005\" target='_blank' rel='noopener noreferrer'>https://www.melonbooks.co.jp/detail/detail.php?product_id=1746005</a>】");
|
|
119
|
-
expect(illustDetail.data.illust.restrict).toBe(0);
|
|
120
|
-
expect(illustDetail.data.illust.user.id).toBe(8166267);
|
|
121
|
-
expect(illustDetail.data.illust.user.name).toBe('くらうど');
|
|
122
|
-
expect(illustDetail.data.illust.user.account).toBe('borinn0812');
|
|
123
|
-
// https://i.pximg.net/user-profile/img/
|
|
124
|
-
expect(illustDetail.data.illust.user.profile_image_urls.medium).toMatch(/^https:\/\/i\.pximg\.net\/user-profile\/img\/.+\.(?:jpg|png)$/);
|
|
125
|
-
expect(illustDetail.data.illust.tags.length).toBeGreaterThan(0);
|
|
126
|
-
expect(illustDetail.data.illust.tools).toBeDefined();
|
|
127
|
-
expect(illustDetail.data.illust.tools.length).toBeGreaterThan(0);
|
|
128
|
-
expect(illustDetail.data.illust.create_date).toBe('2022-12-25T18:31:02+09:00');
|
|
129
|
-
expect(illustDetail.data.illust.page_count).toBe(8);
|
|
130
|
-
expect(illustDetail.data.illust.width).toBe(2508);
|
|
131
|
-
expect(illustDetail.data.illust.height).toBe(3541);
|
|
132
|
-
expect(illustDetail.data.illust.sanity_level).toBe(2);
|
|
133
|
-
expect(illustDetail.data.illust.x_restrict).toBe(0);
|
|
134
|
-
expect(illustDetail.data.illust.series).toBeNull();
|
|
135
|
-
expect(illustDetail.data.illust.meta_single_page).toStrictEqual({});
|
|
136
|
-
expect(illustDetail.data.illust.meta_pages).toHaveLength(8);
|
|
137
|
-
expect(illustDetail.data.illust.total_bookmarks).toBeGreaterThan(0);
|
|
138
|
-
expect(illustDetail.data.illust.total_view).toBeGreaterThan(0);
|
|
139
|
-
expect(illustDetail.data.illust.visible).toBe(true);
|
|
140
|
-
expect(illustDetail.data.illust.illust_ai_type).toBe(1);
|
|
141
|
-
expect(illustDetail.data.illust.illust_book_style).toBe(0);
|
|
142
|
-
const check = new detail_1.GetV1IllustDetailCheck();
|
|
143
|
-
expect(() => check.throwIfResponseFailed(illustDetail.data)).not.toThrow();
|
|
144
|
-
expect((0, utils_1.omit)(illustDetail.data.illust, [
|
|
145
|
-
'total_bookmarks',
|
|
146
|
-
'total_comments',
|
|
147
|
-
'total_view',
|
|
148
|
-
])).toMatchSnapshot();
|
|
149
|
-
});
|
|
150
|
-
it('illustRelated:107565629[illust]', async () => {
|
|
151
|
-
const illustRelated = await pixiv.illustRelated({
|
|
152
|
-
illustId: 107565629,
|
|
153
|
-
});
|
|
154
|
-
expect(illustRelated.status).toBe(200);
|
|
155
|
-
expect(illustRelated.data.illusts).toBeDefined();
|
|
156
|
-
expect(illustRelated.data.illusts.length).toBeGreaterThan(0);
|
|
157
|
-
const check = new related_2.GetV2IllustRelatedCheck();
|
|
158
|
-
expect(() => check.throwIfResponseFailed(illustRelated.data)).not.toThrow();
|
|
159
|
-
});
|
|
160
|
-
it('ugoiraDetail:83638393[ugoira]', async () => {
|
|
161
|
-
const ugoiraDetail = await pixiv.ugoiraMetadata({
|
|
162
|
-
illustId: 83638393,
|
|
163
|
-
});
|
|
164
|
-
expect(ugoiraDetail.status).toBe(200);
|
|
165
|
-
// "medium": "https://i.pximg.net/img-zip-ugoira/img/2014/06/28/12/42/39/44360221_ugoira600x600.zip".
|
|
166
|
-
expect(ugoiraDetail.data.ugoira_metadata.zip_urls.medium).toMatch(/^https:\/\/i\.pximg\.net\/img-zip-ugoira\/img\/.+_ugoira600x600\.zip$/);
|
|
167
|
-
expect(ugoiraDetail.data.ugoira_metadata.frames).toHaveLength(96);
|
|
168
|
-
});
|
|
169
|
-
it('searchIllust', async () => {
|
|
170
|
-
const searchIllust = await pixiv.searchIllust({
|
|
171
|
-
word: 'ホロライブ',
|
|
172
|
-
});
|
|
173
|
-
expect(searchIllust.status).toBe(200);
|
|
174
|
-
expect(searchIllust.data).toBeDefined();
|
|
175
|
-
expect(searchIllust.data.illusts).toBeDefined();
|
|
176
|
-
expect(searchIllust.data.illusts.length).toBeGreaterThan(0);
|
|
177
|
-
const check = new illust_1.GetV1SearchIllustCheck();
|
|
178
|
-
expect(() => check.throwIfResponseFailed(searchIllust.data)).not.toThrow();
|
|
179
|
-
});
|
|
180
|
-
it('illustRanking', async () => {
|
|
181
|
-
const illustRanking = await pixiv.illustRanking();
|
|
182
|
-
expect(illustRanking.status).toBe(200);
|
|
183
|
-
expect(illustRanking.data).toBeDefined();
|
|
184
|
-
expect(illustRanking.data.illusts).toBeDefined();
|
|
185
|
-
expect(illustRanking.data.illusts.length).toBeGreaterThan(0);
|
|
186
|
-
const check = new ranking_1.GetV1IllustRankingCheck();
|
|
187
|
-
expect(() => check.throwIfResponseFailed(illustRanking.data)).not.toThrow();
|
|
188
|
-
});
|
|
189
|
-
it('illustRecommended', async () => {
|
|
190
|
-
const recommendedIllust = await pixiv.illustRecommended();
|
|
191
|
-
expect(recommendedIllust.status).toBe(200);
|
|
192
|
-
expect(recommendedIllust.data).toBeDefined();
|
|
193
|
-
expect(recommendedIllust.data.illusts).toBeDefined();
|
|
194
|
-
expect(recommendedIllust.data.illusts.length).toBeGreaterThan(0);
|
|
195
|
-
const check = new recommended_1.GetV1IllustRecommendedCheck();
|
|
196
|
-
expect(() => check.throwIfResponseFailed(recommendedIllust.data)).not.toThrow();
|
|
197
|
-
});
|
|
198
|
-
it('illustSeries', async () => {
|
|
199
|
-
const illustSeries = await pixiv.illustSeries({
|
|
200
|
-
illustSeriesId: 147483,
|
|
201
|
-
});
|
|
202
|
-
expect(illustSeries.status).toBe(200);
|
|
203
|
-
expect(illustSeries.data).toBeDefined();
|
|
204
|
-
expect(illustSeries.data.illust_series_detail.title).toBe('ホロライブ学パロ');
|
|
205
|
-
expect(illustSeries.data.illusts).toBeDefined();
|
|
206
|
-
expect(illustSeries.data.illusts.length).toBeGreaterThan(0);
|
|
207
|
-
const check = new series_1.GetV1IllustSeriesCheck();
|
|
208
|
-
expect(() => check.throwIfResponseFailed(illustSeries.data)).not.toThrow();
|
|
209
|
-
expect((0, utils_1.omit)(illustSeries.data.illust_series_detail, ['series_work_count'])).toMatchSnapshot('illust_series_detail');
|
|
210
|
-
expect((0, utils_1.omit)(illustSeries.data.illust_series_first_illust, [
|
|
211
|
-
'total_bookmarks',
|
|
212
|
-
'total_comments',
|
|
213
|
-
'total_view',
|
|
214
|
-
])).toMatchSnapshot('illust_series_first_illust');
|
|
215
|
-
});
|
|
216
|
-
it('mangaRecommended', async () => {
|
|
217
|
-
const mangaRecommended = await pixiv.mangaRecommended();
|
|
218
|
-
expect(mangaRecommended.status).toBe(200);
|
|
219
|
-
expect(mangaRecommended.data).toBeDefined();
|
|
220
|
-
expect(mangaRecommended.data.illusts).toBeDefined();
|
|
221
|
-
expect(mangaRecommended.data.illusts.length).toBeGreaterThan(0);
|
|
222
|
-
const check = new recommended_2.GetV1MangaRecommendedCheck();
|
|
223
|
-
expect(() => check.throwIfResponseFailed(mangaRecommended.data)).not.toThrow();
|
|
224
|
-
});
|
|
225
|
-
it('novelDetail', async () => {
|
|
226
|
-
const novelDetail = await pixiv.novelDetail({
|
|
227
|
-
novelId: 13574875,
|
|
228
|
-
});
|
|
229
|
-
expect(novelDetail.status).toBe(200);
|
|
230
|
-
expect(novelDetail.data).toBeDefined();
|
|
231
|
-
expect(novelDetail.data.novel).toBeDefined();
|
|
232
|
-
expect(novelDetail.data.novel.id).toBe(13574875);
|
|
233
|
-
expect(novelDetail.data.novel.title).toBe('それはまるで鍵盤を奏でる細指の如く');
|
|
234
|
-
expect(novelDetail.data.novel.caption).toBe('色々と独自解釈、設定捏造があります。<br />張り詰めるものが多いと、人はいつか破裂する。<br /><br />Twitterやってます→【<strong><a href="https://twitter.com/somari1101" target="_blank">twitter/somari1101</a></strong>】');
|
|
235
|
-
expect(novelDetail.data.novel.restrict).toBe(0);
|
|
236
|
-
expect(novelDetail.data.novel.x_restrict).toBe(0);
|
|
237
|
-
expect(novelDetail.data.novel.is_original).toBe(false);
|
|
238
|
-
expect(novelDetail.data.novel.image_urls).toBeDefined();
|
|
239
|
-
expect(novelDetail.data.novel.image_urls.large).toMatch(/^https:\/\/i\.pximg\.net\/c\/240x480_80\/novel-cover-master\/img\/.+_master1200\.jpg$/);
|
|
240
|
-
expect(novelDetail.data.novel.image_urls.medium).toMatch(/^https:\/\/i\.pximg\.net\/c\/176x352\/novel-cover-master\/img\/.+_master1200\.jpg$/);
|
|
241
|
-
expect(novelDetail.data.novel.image_urls.square_medium).toMatch(/^https:\/\/i\.pximg\.net\/c\/128x128\/novel-cover-master\/img\/.+_square1200\.jpg$/);
|
|
242
|
-
expect(novelDetail.data.novel.create_date).toBe('2020-08-22T21:24:48+09:00');
|
|
243
|
-
expect(novelDetail.data.novel.page_count).toBe(7);
|
|
244
|
-
expect(novelDetail.data.novel.text_length).toBe(6931);
|
|
245
|
-
expect(novelDetail.data.novel.user).toBeDefined();
|
|
246
|
-
expect(novelDetail.data.novel.user.id).toBe(53003997);
|
|
247
|
-
expect(novelDetail.data.novel.user.name).toBe('蘇鞠-そまり-');
|
|
248
|
-
expect(novelDetail.data.novel.user.account).toBe('user_wrmt2824');
|
|
249
|
-
expect(novelDetail.data.novel.user.profile_image_urls).toBeDefined();
|
|
250
|
-
expect(novelDetail.data.novel.user.profile_image_urls.medium).toMatch(/^https:\/\/i\.pximg\.net\/user-profile\/img\/.+\.(?:jpg|png)$/);
|
|
251
|
-
expect(novelDetail.data.novel.user.is_followed).toBeDefined();
|
|
252
|
-
expect(novelDetail.data.novel.series).toStrictEqual({});
|
|
253
|
-
expect(novelDetail.data.novel.is_bookmarked).toBeDefined();
|
|
254
|
-
expect(novelDetail.data.novel.total_bookmarks).toBeGreaterThan(0);
|
|
255
|
-
expect(novelDetail.data.novel.total_view).toBeGreaterThan(0);
|
|
256
|
-
expect(novelDetail.data.novel.visible).toBe(true);
|
|
257
|
-
expect(novelDetail.data.novel.total_comments).toBeGreaterThan(0);
|
|
258
|
-
expect(novelDetail.data.novel.is_muted).toBeDefined();
|
|
259
|
-
expect(novelDetail.data.novel.is_mypixiv_only).toBeDefined();
|
|
260
|
-
expect(novelDetail.data.novel.is_x_restricted).toBe(false);
|
|
261
|
-
expect(novelDetail.data.novel.novel_ai_type).toBe(0);
|
|
262
|
-
const check = new detail_3.GetV2NovelDetailCheck();
|
|
263
|
-
expect(() => check.throwIfResponseFailed(novelDetail.data)).not.toThrow();
|
|
264
|
-
expect((0, utils_1.omit)(novelDetail.data.novel, [
|
|
265
|
-
'total_bookmarks',
|
|
266
|
-
'total_comments',
|
|
267
|
-
'total_view',
|
|
268
|
-
])).toMatchSnapshot();
|
|
269
|
-
});
|
|
270
|
-
it('novelText', async () => {
|
|
271
|
-
const novelText = await pixiv.novelText({
|
|
272
|
-
id: 13574875,
|
|
273
|
-
});
|
|
274
|
-
expect(novelText.status).toBe(200);
|
|
275
|
-
expect(novelText.data).toBeDefined();
|
|
276
|
-
});
|
|
277
|
-
it('novelRelated:13_574_875[novel]', async () => {
|
|
278
|
-
const viewed = [
|
|
279
|
-
19257307, 14823759, 18139010, 20311890, 19219621, 13254987,
|
|
280
|
-
19228582, 19692090, 20571910, 20451982, 15018893, 16748181,
|
|
281
|
-
15885571, 12981294, 16331599, 16962597, 16381107,
|
|
282
|
-
];
|
|
283
|
-
const novelRelated = await pixiv.novelRelated({
|
|
284
|
-
novelId: 13574875,
|
|
285
|
-
seedNovelIds: [13574875],
|
|
286
|
-
viewed,
|
|
287
|
-
});
|
|
288
|
-
expect(novelRelated.status).toBe(200);
|
|
289
|
-
expect(novelRelated.data).toBeDefined();
|
|
290
|
-
expect(novelRelated.data.novels).toBeDefined();
|
|
291
|
-
expect(novelRelated.data.novels.length).toBeGreaterThan(0);
|
|
292
|
-
expect(novelRelated.data.novels.filter((novel) => viewed.includes(novel.id))).toHaveLength(0);
|
|
293
|
-
const check = new related_1.GetV1NovelRelatedCheck();
|
|
294
|
-
expect(() => check.throwIfResponseFailed(novelRelated.data)).not.toThrow();
|
|
295
|
-
});
|
|
296
|
-
it('novelRanking', async () => {
|
|
297
|
-
const novelRanking = await pixiv.novelRanking();
|
|
298
|
-
expect(novelRanking.status).toBe(200);
|
|
299
|
-
expect(novelRanking.data).toBeDefined();
|
|
300
|
-
expect(novelRanking.data.novels).toBeDefined();
|
|
301
|
-
expect(novelRanking.data.novels.length).toBeGreaterThan(0);
|
|
302
|
-
const check = new ranking_2.GetV1NovelRankingCheck();
|
|
303
|
-
expect(() => check.throwIfResponseFailed(novelRanking.data)).not.toThrow();
|
|
304
|
-
});
|
|
305
|
-
it('searchNovel', async () => {
|
|
306
|
-
const searchNovel = await pixiv.searchNovel({
|
|
307
|
-
word: 'ホロライブ',
|
|
308
|
-
});
|
|
309
|
-
expect(searchNovel.status).toBe(200);
|
|
310
|
-
expect(searchNovel.data).toBeDefined();
|
|
311
|
-
expect(searchNovel.data.novels).toBeDefined();
|
|
312
|
-
expect(searchNovel.data.novels.length).toBeGreaterThan(0);
|
|
313
|
-
const check = new novel_1.GetV1SearchNovelCheck();
|
|
314
|
-
expect(() => check.throwIfResponseFailed(searchNovel.data)).not.toThrow();
|
|
315
|
-
});
|
|
316
|
-
it('novelRecommended', async () => {
|
|
317
|
-
const novelRecommended = await pixiv.novelRecommended();
|
|
318
|
-
expect(novelRecommended.status).toBe(200);
|
|
319
|
-
expect(novelRecommended.data).toBeDefined();
|
|
320
|
-
expect(novelRecommended.data.novels).toBeDefined();
|
|
321
|
-
expect(novelRecommended.data.novels.length).toBeGreaterThan(0);
|
|
322
|
-
const check = new recommended_3.GetV1NovelRecommendedCheck();
|
|
323
|
-
expect(() => check.throwIfResponseFailed(novelRecommended.data)).not.toThrow();
|
|
324
|
-
});
|
|
325
|
-
it('novelSeries', async () => {
|
|
326
|
-
const novelSeries = await pixiv.novelSeries({
|
|
327
|
-
seriesId: 7474721,
|
|
328
|
-
});
|
|
329
|
-
expect(novelSeries.status).toBe(200);
|
|
330
|
-
expect(novelSeries.data).toBeDefined();
|
|
331
|
-
expect(novelSeries.data.novel_series_detail.title).toBe('夏色吹雪の恋人生活');
|
|
332
|
-
expect(novelSeries.data.novels).toBeDefined();
|
|
333
|
-
expect(novelSeries.data.novels.length).toBeGreaterThan(0);
|
|
334
|
-
const check = new series_2.GetV2NovelSeriesCheck();
|
|
335
|
-
expect(() => check.throwIfResponseFailed(novelSeries.data)).not.toThrow();
|
|
336
|
-
expect((0, utils_1.omit)(novelSeries.data.novel_series_detail, ['content_count'])).toMatchSnapshot('novel_series_detail');
|
|
337
|
-
expect((0, utils_1.omit)(novelSeries.data.novel_series_first_novel, [
|
|
338
|
-
'total_bookmarks',
|
|
339
|
-
'total_comments',
|
|
340
|
-
'total_view',
|
|
341
|
-
])).toMatchSnapshot('novel_series_first_novel');
|
|
342
|
-
expect((0, utils_1.omit)(novelSeries.data.novel_series_latest_novel, [
|
|
343
|
-
'total_bookmarks',
|
|
344
|
-
'total_comments',
|
|
345
|
-
'total_view',
|
|
346
|
-
])).toMatchSnapshot('illust_series_first_illust');
|
|
347
|
-
});
|
|
348
|
-
it('userDetail', async () => {
|
|
349
|
-
const userDetail = await pixiv.userDetail({
|
|
350
|
-
userId: 16568776,
|
|
351
|
-
});
|
|
352
|
-
expect(userDetail.status).toBe(200);
|
|
353
|
-
expect(userDetail.data).toBeDefined();
|
|
354
|
-
expect(userDetail.data.user).toBeDefined();
|
|
355
|
-
expect(userDetail.data.user.id).toBe(16568776);
|
|
356
|
-
expect(userDetail.data.user.name).toBe('ihcamot');
|
|
357
|
-
const check = new detail_2.GetV1UserDetailCheck();
|
|
358
|
-
expect(() => check.throwIfResponseFailed(userDetail.data)).not.toThrow();
|
|
359
|
-
expect(userDetail.data.user).toMatchSnapshot('user');
|
|
360
|
-
expect((0, utils_1.omit)(userDetail.data.profile, [
|
|
361
|
-
'total_follow_users',
|
|
362
|
-
'total_illust_bookmarks_public',
|
|
363
|
-
])).toMatchSnapshot('profile');
|
|
364
|
-
expect(userDetail.data.profile_publicity).toMatchSnapshot('profile_publicity');
|
|
365
|
-
expect(userDetail.data.workspace).toMatchSnapshot('workspace');
|
|
366
|
-
});
|
|
367
|
-
it('userBookmarksIllust', async () => {
|
|
368
|
-
const userBookmarksIllust = await pixiv.userBookmarksIllust({
|
|
369
|
-
userId: 16568776,
|
|
370
|
-
restrict: options_1.BookmarkRestrict.PRIVATE,
|
|
371
|
-
});
|
|
372
|
-
expect(userBookmarksIllust.status).toBe(200);
|
|
373
|
-
expect(userBookmarksIllust.data).toBeDefined();
|
|
374
|
-
expect(userBookmarksIllust.data.illusts).toBeDefined();
|
|
375
|
-
expect(userBookmarksIllust.data.illusts.length).toBeGreaterThan(0);
|
|
376
|
-
const check = new illust_2.GetV1UserBookmarksIllustCheck();
|
|
377
|
-
expect(() => check.throwIfResponseFailed(userBookmarksIllust.data)).not.toThrow();
|
|
378
|
-
});
|
|
379
|
-
it('userBookmarksNovel', async () => {
|
|
380
|
-
const userBookmarksNovel = await pixiv.userBookmarksNovel({
|
|
381
|
-
userId: 16568776,
|
|
382
|
-
restrict: options_1.BookmarkRestrict.PRIVATE,
|
|
383
|
-
});
|
|
384
|
-
expect(userBookmarksNovel.status).toBe(200);
|
|
385
|
-
expect(userBookmarksNovel.data).toBeDefined();
|
|
386
|
-
expect(userBookmarksNovel.data.novels).toBeDefined();
|
|
387
|
-
expect(userBookmarksNovel.data.novels.length).toBeGreaterThan(0);
|
|
388
|
-
const check = new novel_2.GetV1UserBookmarksNovelCheck();
|
|
389
|
-
expect(() => check.throwIfResponseFailed(userBookmarksNovel.data)).not.toThrow();
|
|
390
|
-
});
|
|
391
|
-
async function restoreBookmarkState(illustId) {
|
|
392
|
-
await pixiv.illustBookmarkAdd({
|
|
393
|
-
illustId,
|
|
394
|
-
restrict: options_1.BookmarkRestrict.PUBLIC,
|
|
395
|
-
tags: [],
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
it('illustBookmarkAdd and illustBookmarkDelete', async () => {
|
|
399
|
-
// テスト用のイラストID(実際に存在するイラストを使用)
|
|
400
|
-
const illustId = 107565629; // 正しい桁区切り
|
|
401
|
-
// テスト前にブックマーク状態を確認
|
|
402
|
-
const initialDetail = await pixiv.illustDetail({
|
|
403
|
-
illustId,
|
|
404
|
-
});
|
|
405
|
-
const wasBookmarked = initialDetail.data.illust.is_bookmarked;
|
|
406
|
-
try {
|
|
407
|
-
// ブックマーク状態に応じてテストを実行
|
|
408
|
-
if (wasBookmarked) {
|
|
409
|
-
// すでにブックマークされている場合は削除→追加のテスト
|
|
410
|
-
const bookmarkDeleteResult = await pixiv.illustBookmarkDelete({
|
|
411
|
-
illustId: String(illustId),
|
|
412
|
-
});
|
|
413
|
-
expect(bookmarkDeleteResult.status).toBe(200);
|
|
414
|
-
const bookmarkAddResult = await pixiv.illustBookmarkAdd({
|
|
415
|
-
illustId,
|
|
416
|
-
restrict: options_1.BookmarkRestrict.PUBLIC,
|
|
417
|
-
tags: ['テスト'],
|
|
418
|
-
});
|
|
419
|
-
expect(bookmarkAddResult.status).toBe(200);
|
|
420
|
-
}
|
|
421
|
-
else {
|
|
422
|
-
// ブックマークされていない場合は追加→削除のテスト
|
|
423
|
-
const bookmarkAddResult = await pixiv.illustBookmarkAdd({
|
|
424
|
-
illustId,
|
|
425
|
-
restrict: options_1.BookmarkRestrict.PUBLIC,
|
|
426
|
-
tags: ['テスト'],
|
|
427
|
-
});
|
|
428
|
-
expect(bookmarkAddResult.status).toBe(200);
|
|
429
|
-
const bookmarkDeleteResult = await pixiv.illustBookmarkDelete({
|
|
430
|
-
illustId: String(illustId),
|
|
431
|
-
});
|
|
432
|
-
expect(bookmarkDeleteResult.status).toBe(200);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
finally {
|
|
436
|
-
await restoreBookmarkState(illustId);
|
|
437
|
-
}
|
|
438
|
-
});
|
|
439
|
-
it('novelBookmarkAdd and novelBookmarkDelete', async () => {
|
|
440
|
-
// テスト用の小説ID(実際に存在する小説を使用)
|
|
441
|
-
const novelId = 13574875; // 数値型としてdetail取得用に定義(正しい桁区切り)
|
|
442
|
-
const novelIdStr = '13574875'; // 文字列型としてブックマーク用に定義
|
|
443
|
-
// テスト前にブックマーク状態を確認
|
|
444
|
-
const initialDetail = await pixiv.novelDetail({
|
|
445
|
-
novelId,
|
|
446
|
-
});
|
|
447
|
-
const wasBookmarked = initialDetail.data.novel.is_bookmarked;
|
|
448
|
-
try {
|
|
449
|
-
// ブックマーク状態に応じてテストを実行
|
|
450
|
-
if (wasBookmarked) {
|
|
451
|
-
// すでにブックマークされている場合は削除→追加のテスト
|
|
452
|
-
const novelBookmarkDeleteResult = await pixiv.novelBookmarkDelete({
|
|
453
|
-
novelId: novelIdStr, // 文字列型を渡す
|
|
454
|
-
});
|
|
455
|
-
expect(novelBookmarkDeleteResult.status).toBe(200);
|
|
456
|
-
const novelBookmarkAddResult = await pixiv.novelBookmarkAdd({
|
|
457
|
-
novelId: novelIdStr, // 文字列型を渡す
|
|
458
|
-
restrict: options_1.BookmarkRestrict.PUBLIC,
|
|
459
|
-
tags: ['テスト'],
|
|
460
|
-
});
|
|
461
|
-
expect(novelBookmarkAddResult.status).toBe(200);
|
|
462
|
-
}
|
|
463
|
-
else {
|
|
464
|
-
// ブックマークされていない場合は追加→削除のテスト
|
|
465
|
-
const novelBookmarkAddResult = await pixiv.novelBookmarkAdd({
|
|
466
|
-
novelId: novelIdStr, // 文字列型を渡す
|
|
467
|
-
restrict: options_1.BookmarkRestrict.PUBLIC,
|
|
468
|
-
tags: ['テスト'],
|
|
469
|
-
});
|
|
470
|
-
expect(novelBookmarkAddResult.status).toBe(200);
|
|
471
|
-
const novelBookmarkDeleteResult = await pixiv.novelBookmarkDelete({
|
|
472
|
-
novelId: novelIdStr, // 文字列型を渡す
|
|
473
|
-
});
|
|
474
|
-
expect(novelBookmarkDeleteResult.status).toBe(200);
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
finally {
|
|
478
|
-
// テスト後に元のブックマーク状態に戻す
|
|
479
|
-
if (wasBookmarked) {
|
|
480
|
-
// 元々ブックマークされていた場合、ブックマークを確実に追加
|
|
481
|
-
await pixiv.novelBookmarkAdd({
|
|
482
|
-
novelId: novelIdStr, // 文字列型を渡す
|
|
483
|
-
restrict: options_1.BookmarkRestrict.PUBLIC,
|
|
484
|
-
tags: [],
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
else {
|
|
488
|
-
// 元々ブックマークされていなかった場合、ブックマークを確実に削除
|
|
489
|
-
try {
|
|
490
|
-
await pixiv.novelBookmarkDelete({
|
|
491
|
-
novelId: novelIdStr, // 文字列型を渡す
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
catch {
|
|
495
|
-
// すでに削除済みの場合はエラーを無視
|
|
496
|
-
// エラーハンドリング用のコメント
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
describe('utility methods', () => {
|
|
502
|
-
it('parseQueryString', () => {
|
|
503
|
-
const qs = 'https://example.com?a=1&b=2&c=3';
|
|
504
|
-
const parsed = pixiv_1.default.parseQueryString(qs);
|
|
505
|
-
expect(parsed).toStrictEqual({
|
|
506
|
-
a: '1',
|
|
507
|
-
b: '2',
|
|
508
|
-
c: '3',
|
|
509
|
-
});
|
|
510
|
-
});
|
|
511
|
-
it('isError', () => {
|
|
512
|
-
const error = {
|
|
513
|
-
error: {
|
|
514
|
-
user_message: 'Rate limit exceeded.',
|
|
515
|
-
message: '',
|
|
516
|
-
reason: '',
|
|
517
|
-
},
|
|
518
|
-
};
|
|
519
|
-
expect(pixiv_1.default.isError(error)).toBe(true);
|
|
520
|
-
const notError = {
|
|
521
|
-
data: {
|
|
522
|
-
result: 'success',
|
|
523
|
-
},
|
|
524
|
-
};
|
|
525
|
-
expect(pixiv_1.default.isError(notError)).toBe(false);
|
|
526
|
-
});
|
|
527
|
-
it('checkRequiredOptions', () => {
|
|
528
|
-
// thisバインディングを持つアロー関数として定義(バインディング問題を解決)
|
|
529
|
-
const pixivInstance = pixiv;
|
|
530
|
-
const checkRequiredOptions = (options, requiredOptions) => {
|
|
531
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
532
|
-
return pixivInstance.checkRequiredOptions(options, requiredOptions);
|
|
533
|
-
};
|
|
534
|
-
expect(() => {
|
|
535
|
-
checkRequiredOptions({ illustId: 123 }, ['illustId']);
|
|
536
|
-
}).not.toThrow();
|
|
537
|
-
expect(() => {
|
|
538
|
-
checkRequiredOptions({}, ['illustId']);
|
|
539
|
-
}).toThrow('Missing required option: illustId');
|
|
540
|
-
expect(() => {
|
|
541
|
-
checkRequiredOptions({ illustId: 123, userId: 456 }, [
|
|
542
|
-
'illustId',
|
|
543
|
-
'userId',
|
|
544
|
-
]);
|
|
545
|
-
}).not.toThrow();
|
|
546
|
-
expect(() => {
|
|
547
|
-
checkRequiredOptions({ illustId: 123 }, ['illustId', 'userId']);
|
|
548
|
-
}).toThrow('Missing required option: userId');
|
|
549
|
-
});
|
|
550
|
-
it('convertCamelToSnake', () => {
|
|
551
|
-
// thisバインディングを持つアロー関数として定義
|
|
552
|
-
const pixivInstance = pixiv;
|
|
553
|
-
const convertCamelToSnake = (obj) => {
|
|
554
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
555
|
-
return pixivInstance.convertCamelToSnake(obj);
|
|
556
|
-
};
|
|
557
|
-
expect(convertCamelToSnake({
|
|
558
|
-
illustId: 123,
|
|
559
|
-
maxBookmarkId: 456,
|
|
560
|
-
userDetailInfo: true,
|
|
561
|
-
})).toStrictEqual({
|
|
562
|
-
illust_id: 123,
|
|
563
|
-
max_bookmark_id: 456,
|
|
564
|
-
user_detail_info: true,
|
|
565
|
-
});
|
|
566
|
-
expect(convertCamelToSnake({
|
|
567
|
-
id: 123,
|
|
568
|
-
name: 'test',
|
|
569
|
-
})).toStrictEqual({
|
|
570
|
-
id: 123,
|
|
571
|
-
name: 'test',
|
|
572
|
-
});
|
|
573
|
-
});
|
|
574
|
-
it('isJSON', () => {
|
|
575
|
-
// thisバインディングを持つアロー関数として定義
|
|
576
|
-
const pixivInstance = pixiv;
|
|
577
|
-
const isJSON = (value) => {
|
|
578
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
579
|
-
return pixivInstance.isJSON(value);
|
|
580
|
-
};
|
|
581
|
-
expect(isJSON({ key: 'value' })).toBe(true);
|
|
582
|
-
expect(isJSON('{"key":"value"}')).toBe(true);
|
|
583
|
-
expect(isJSON('invalid json')).toBe(false);
|
|
584
|
-
});
|
|
585
|
-
});
|
|
586
|
-
});
|
|
587
|
-
describe('Pixiv class coverage tests', () => {
|
|
588
|
-
describe('of method', () => {
|
|
589
|
-
// 行245のカバレッジ: トークンリフレッシュ失敗のテスト
|
|
590
|
-
it('should throw an error when refresh token fails', async () => {
|
|
591
|
-
// モック化してエラーを起こす
|
|
592
|
-
const originalAxiosPost = axios_1.default.post;
|
|
593
|
-
try {
|
|
594
|
-
// axiosをモック化し、トークンリフレッシュが失敗するようにする
|
|
595
|
-
axios_1.default.post = jest.fn().mockResolvedValueOnce({
|
|
596
|
-
status: 401,
|
|
597
|
-
data: {
|
|
598
|
-
error: 'invalid_token',
|
|
599
|
-
message: 'Invalid refresh token',
|
|
600
|
-
},
|
|
601
|
-
});
|
|
602
|
-
await expect(pixiv_1.default.of('invalid_refresh_token')).rejects.toThrow('Failed to refresh token');
|
|
603
|
-
}
|
|
604
|
-
finally {
|
|
605
|
-
// モックを元に戻す
|
|
606
|
-
axios_1.default.post = originalAxiosPost;
|
|
607
|
-
}
|
|
608
|
-
});
|
|
609
|
-
// 行276のカバレッジ: データベースなしの場合
|
|
610
|
-
it('should initialize without response database', async () => {
|
|
611
|
-
const originalAxiosPost = axios_1.default.post;
|
|
612
|
-
try {
|
|
613
|
-
// モックでPOSTメソッドが成功を返すようにする
|
|
614
|
-
axios_1.default.post = jest.fn().mockResolvedValueOnce({
|
|
615
|
-
status: 200,
|
|
616
|
-
data: {
|
|
617
|
-
user: { id: 'test_user_id' },
|
|
618
|
-
response: {
|
|
619
|
-
access_token: 'test_access_token',
|
|
620
|
-
refresh_token: 'test_refresh_token',
|
|
621
|
-
},
|
|
622
|
-
},
|
|
623
|
-
});
|
|
624
|
-
// データベースオプションなしでインスタンス化
|
|
625
|
-
const instance = await pixiv_1.default.of('test_refresh_token', {
|
|
626
|
-
debugOptions: {
|
|
627
|
-
outputResponse: {
|
|
628
|
-
enable: false,
|
|
629
|
-
},
|
|
630
|
-
},
|
|
631
|
-
});
|
|
632
|
-
expect(instance).toBeInstanceOf(pixiv_1.default);
|
|
633
|
-
await instance.close();
|
|
634
|
-
}
|
|
635
|
-
finally {
|
|
636
|
-
// モックを元に戻す
|
|
637
|
-
axios_1.default.post = originalAxiosPost;
|
|
638
|
-
}
|
|
639
|
-
});
|
|
640
|
-
});
|
|
641
|
-
describe('request method', () => {
|
|
642
|
-
let pixiv;
|
|
643
|
-
let requestSpy;
|
|
644
|
-
beforeAll(async () => {
|
|
645
|
-
// テスト用のPixivインスタンスを生成
|
|
646
|
-
const originalAxiosPost = axios_1.default.post;
|
|
647
|
-
try {
|
|
648
|
-
// モックでPOSTメソッドが成功を返すようにする
|
|
649
|
-
axios_1.default.post = jest.fn().mockResolvedValueOnce({
|
|
650
|
-
status: 200,
|
|
651
|
-
data: {
|
|
652
|
-
user: { id: 'test_user_id' },
|
|
653
|
-
response: {
|
|
654
|
-
access_token: 'test_access_token',
|
|
655
|
-
refresh_token: 'test_refresh_token',
|
|
656
|
-
},
|
|
657
|
-
},
|
|
658
|
-
});
|
|
659
|
-
pixiv = await pixiv_1.default.of('test_refresh_token');
|
|
660
|
-
}
|
|
661
|
-
finally {
|
|
662
|
-
// モックを元に戻す
|
|
663
|
-
axios_1.default.post = originalAxiosPost;
|
|
664
|
-
}
|
|
665
|
-
});
|
|
666
|
-
afterAll(async () => {
|
|
667
|
-
// テスト終了後にインスタンスをクリーンアップ
|
|
668
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
669
|
-
if (pixiv) {
|
|
670
|
-
await pixiv.close();
|
|
671
|
-
}
|
|
672
|
-
});
|
|
673
|
-
beforeEach(() => {
|
|
674
|
-
// requestメソッドをスパイ
|
|
675
|
-
requestSpy = jest.spyOn(pixiv, 'request');
|
|
676
|
-
});
|
|
677
|
-
afterEach(() => {
|
|
678
|
-
// スパイをリセット
|
|
679
|
-
requestSpy.mockRestore();
|
|
680
|
-
});
|
|
681
|
-
// 行898のカバレッジ: 無効なHTTPメソッド
|
|
682
|
-
it('should throw an error with invalid HTTP method', async () => {
|
|
683
|
-
// 基本的にrequest()は直接呼び出せないのでモックして内部で例外を投げさせる
|
|
684
|
-
requestSpy.mockImplementationOnce(() => {
|
|
685
|
-
throw new Error('Invalid method');
|
|
686
|
-
});
|
|
687
|
-
await expect(pixiv.illustDetail({ illustId: 123 })).rejects.toThrow('Invalid method');
|
|
688
|
-
});
|
|
689
|
-
// 行906のカバレッジ: レスポンスURLフォールバック
|
|
690
|
-
it('should use fallback URL when responseUrl is undefined', async () => {
|
|
691
|
-
// saveResponseメソッドをスパイ
|
|
692
|
-
const saveResponseSpy = jest.spyOn(pixiv, 'saveResponse');
|
|
693
|
-
// 元のaxios.getをバックアップ
|
|
694
|
-
const originalAxiosGet = pixiv.axios.get;
|
|
695
|
-
try {
|
|
696
|
-
// モック化
|
|
697
|
-
pixiv.axios.get = jest.fn().mockResolvedValueOnce({
|
|
698
|
-
status: 200,
|
|
699
|
-
data: { test: 'data' },
|
|
700
|
-
config: {
|
|
701
|
-
headers: {},
|
|
702
|
-
data: null,
|
|
703
|
-
},
|
|
704
|
-
headers: {},
|
|
705
|
-
request: {
|
|
706
|
-
res: {}, // responseUrlプロパティがない
|
|
707
|
-
},
|
|
708
|
-
});
|
|
709
|
-
// レスポンスデータベースが設定されていれば実行
|
|
710
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
711
|
-
if (pixiv.responseDatabase) {
|
|
712
|
-
await pixiv.illustDetail({ illustId: 123 });
|
|
713
|
-
// saveResponseが呼び出されたことを確認
|
|
714
|
-
expect(saveResponseSpy).toHaveBeenCalled();
|
|
715
|
-
}
|
|
716
|
-
else {
|
|
717
|
-
// レスポンスデータベースがない場合はテストをスキップ
|
|
718
|
-
console.log('Test skipped: responseDatabase is not available');
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
finally {
|
|
722
|
-
// モックを元に戻す
|
|
723
|
-
pixiv.axios.get = originalAxiosGet;
|
|
724
|
-
saveResponseSpy.mockRestore();
|
|
725
|
-
}
|
|
726
|
-
});
|
|
727
|
-
});
|
|
728
|
-
});
|
|
729
|
-
//# sourceMappingURL=pixiv.test.js.map
|