e621-client 1.2.0 → 1.2.1
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
CHANGED
|
@@ -79,7 +79,7 @@ describe("E621ApiClient", () => {
|
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
it("should add the query parameters properly", async () => {
|
|
82
|
-
const client = createClient(
|
|
82
|
+
const client = createClient();
|
|
83
83
|
|
|
84
84
|
await client.get({
|
|
85
85
|
route: "test",
|
|
@@ -93,6 +93,41 @@ describe("E621ApiClient", () => {
|
|
|
93
93
|
expect.anything(),
|
|
94
94
|
);
|
|
95
95
|
});
|
|
96
|
+
|
|
97
|
+
it("should pass the credentials in the Authorization header", async () => {
|
|
98
|
+
const client = createClient();
|
|
99
|
+
client.setCredentials({ username: "jest", apiKey: "key" });
|
|
100
|
+
|
|
101
|
+
const expectedHeader = {
|
|
102
|
+
Authorization: `Basic ${Buffer.from("jest:key").toString("base64")}`,
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
await client.get({ route: "test" });
|
|
106
|
+
|
|
107
|
+
expect(fetchMock).toHaveBeenCalledWith(
|
|
108
|
+
expect.anything(),
|
|
109
|
+
expect.objectContaining({
|
|
110
|
+
headers: expect.objectContaining(expectedHeader),
|
|
111
|
+
}),
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("should stop passing the credentials when clearing them", async () => {
|
|
116
|
+
const client = createClient();
|
|
117
|
+
client.setCredentials({ username: "jest", apiKey: "key" });
|
|
118
|
+
client.setCredentials(null);
|
|
119
|
+
|
|
120
|
+
await client.get({ route: "test" });
|
|
121
|
+
|
|
122
|
+
expect(fetchMock).toHaveBeenCalledWith(
|
|
123
|
+
expect.anything(),
|
|
124
|
+
expect.objectContaining({
|
|
125
|
+
headers: expect.not.objectContaining({
|
|
126
|
+
Authorization: expect.anything(),
|
|
127
|
+
}),
|
|
128
|
+
}),
|
|
129
|
+
);
|
|
130
|
+
});
|
|
96
131
|
});
|
|
97
132
|
|
|
98
133
|
describe("specific endpoints", () => {
|