Adding another test.

This commit is contained in:
Dessalines 2024-03-15 09:06:15 -04:00
parent 34938eb4c1
commit 8c73b8d24e
3 changed files with 12 additions and 8 deletions

View file

@ -27,7 +27,7 @@
"eslint": "^8.57.0", "eslint": "^8.57.0",
"eslint-plugin-prettier": "^5.0.1", "eslint-plugin-prettier": "^5.0.1",
"jest": "^29.5.0", "jest": "^29.5.0",
"lemmy-js-client": "0.19.4-alpha.9", "lemmy-js-client": "0.19.4-alpha.10",
"prettier": "^3.2.5", "prettier": "^3.2.5",
"ts-jest": "^29.1.0", "ts-jest": "^29.1.0",
"typescript": "^5.3.3" "typescript": "^5.3.3"

View file

@ -30,8 +30,8 @@ devDependencies:
specifier: ^29.5.0 specifier: ^29.5.0
version: 29.7.0(@types/node@20.11.22) version: 29.7.0(@types/node@20.11.22)
lemmy-js-client: lemmy-js-client:
specifier: 0.19.4-alpha.9 specifier: 0.19.4-alpha.10
version: 0.19.4-alpha.9 version: 0.19.4-alpha.10
prettier: prettier:
specifier: ^3.2.5 specifier: ^3.2.5
version: 3.2.5 version: 3.2.5
@ -2390,8 +2390,8 @@ packages:
engines: {node: '>=6'} engines: {node: '>=6'}
dev: true dev: true
/lemmy-js-client@0.19.4-alpha.9: /lemmy-js-client@0.19.4-alpha.10:
resolution: {integrity: sha512-krvrTXKji+y6huy91Qyav5e5ueKfWPKuKp6eE3OS3IEsyqsleU2drJRt0QAb8Gx/Qw+7V0y5uwWdalrKA5J78A==} resolution: {integrity: sha512-/08YJU2x9KhCj2s9eNG31GlTy3Y7OaTPIhS+3LfZbcHRhYrwgPcIu3/zvh/HgwvpnXEmjo2ToJsH0+RUvSmgpA==}
dependencies: dependencies:
cross-fetch: 4.0.0 cross-fetch: 4.0.0
form-data: 4.0.0 form-data: 4.0.0

View file

@ -49,9 +49,13 @@ test("Upload image and delete it", async () => {
expect(content.length).toBeGreaterThan(0); expect(content.length).toBeGreaterThan(0);
// Ensure that it comes back with the list_media endpoint // Ensure that it comes back with the list_media endpoint
const listMediaRes = await alphaImage.listMedia({}); const listMediaRes = await alphaImage.listMedia();
expect(listMediaRes.images.length).toBe(1); expect(listMediaRes.images.length).toBe(1);
// Ensure that it also comes back with the admin all images
const listAllMediaRes = await alphaImage.listAllMedia();
expect(listAllMediaRes.images.length).toBe(1);
// The deleteUrl is a combination of the endpoint, delete token, and alias // The deleteUrl is a combination of the endpoint, delete token, and alias
let firstImage = listMediaRes.images[0]; let firstImage = listMediaRes.images[0];
let deleteUrl = `${alphaUrl}/pictrs/image/delete/${firstImage.pictrs_delete_token}/${firstImage.pictrs_alias}`; let deleteUrl = `${alphaUrl}/pictrs/image/delete/${firstImage.pictrs_delete_token}/${firstImage.pictrs_alias}`;
@ -70,11 +74,11 @@ test("Upload image and delete it", async () => {
expect(content2).toBe(""); expect(content2).toBe("");
// Ensure that it shows the image is deleted // Ensure that it shows the image is deleted
const deletedListMediaRes = await alphaImage.listMedia({}); const deletedListMediaRes = await alphaImage.listMedia();
expect(deletedListMediaRes.images.length).toBe(0); expect(deletedListMediaRes.images.length).toBe(0);
// Ensure that the admin shows its deleted // Ensure that the admin shows its deleted
const deletedListAllMediaRes = await alphaImage.listAllMedia({}); const deletedListAllMediaRes = await alphaImage.listAllMedia();
expect(deletedListAllMediaRes.images.length).toBe(0); expect(deletedListAllMediaRes.images.length).toBe(0);
}); });