Skip to content

Commit

Permalink
test(*): adds testing todos and cleans up test/src ahead of #88
Browse files Browse the repository at this point in the history
also includes some cleanup and minor updates found in test discovery
  • Loading branch information
KenEucker committed Nov 30, 2021
1 parent a988acb commit 1a7a17f
Show file tree
Hide file tree
Showing 51 changed files with 321 additions and 1,175 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"serve": "eleventy --serve",
"serve:prod": "eleventy --serve --port=80",
"start": "npm run serve:prod",
"test": "jest",
"test": "jest --verbose",
"test:dev": "jest --silent=false",
"test:ci": "jest --ci --coverage --maxWorkers=2",
"build": "tsc",
Expand Down
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ export class BikeTagClient extends EventEmitter {
}
}

/// **************************** Queue Methods **************************************** ///
/// **************************** Queue Data Methods *********************************** ///

queue(
payload?: RequireAtLeastOne<getQueuePayload>,
Expand Down
8 changes: 4 additions & 4 deletions src/imgur/deleteTag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { AvailableApis, HttpStatusCode } from '../common/enums'
export async function deleteTag(
client: ImgurClient,
payload: deleteTagPayload
): Promise<BikeTagApiResponse<any>> {
const responses = []
): Promise<BikeTagApiResponse<boolean[]>> {
const responses: boolean[] = []
const hashes = []

if (payload.tagnumber || payload.slug) {
Expand All @@ -30,13 +30,13 @@ export async function deleteTag(
}

for (const hash of hashes) {
responses.push(await client.deleteImage(hash))
responses.push((await client.deleteImage(hash)).data)
}

return {
data: responses,
success: true,
source: AvailableApis[AvailableApis.imgur],
status: HttpStatusCode.Ok,
} as BikeTagApiResponse<any>
}
}
18 changes: 8 additions & 10 deletions src/imgur/deleteTags.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import ImgurClient from 'imgur'
import { deleteTagsPayload } from '../common/payloads'
import { BikeTagApiResponse, ImgurImage } from '../common/types'
import { BikeTagApiResponse } from '../common/types'
import { getImageHashFromImgurImage } from './helpers'
import { AvailableApis, HttpStatusCode } from '../common/enums'

export async function deleteTag(
export async function deleteTags(
client: ImgurClient,
payload: deleteTagsPayload
): Promise<BikeTagApiResponse<any>> {
const responses = []
): Promise<BikeTagApiResponse<boolean[]>> {
const responses: boolean[] = []
const deleteHashes = []
let tags = payload.tags

Expand All @@ -17,13 +17,11 @@ export async function deleteTag(
}
for (const tag of tags) {
if (tag.foundImageUrl) {
deleteHashes.push(
getImageHashFromImgurImage({ link: tag.foundImageUrl } as ImgurImage)
)
deleteHashes.push(getImageHashFromImgurImage({ link: tag.foundImageUrl }))
}
if (tag.mysteryImageUrl) {
deleteHashes.push(
getImageHashFromImgurImage({ link: tag.mysteryImageUrl } as ImgurImage)
getImageHashFromImgurImage({ link: tag.mysteryImageUrl })
)
}
}
Expand All @@ -33,13 +31,13 @@ export async function deleteTag(
}

for (const hash of deleteHashes) {
responses.push(await client.deleteImage(hash))
responses.push((await client.deleteImage(hash)).data)
}

return {
data: responses,
success: true,
source: AvailableApis[AvailableApis.imgur],
status: HttpStatusCode.Ok,
} as BikeTagApiResponse<any>
}
}
2 changes: 1 addition & 1 deletion src/imgur/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ export const getBikeTagNumberIndexFromImgurImages = (
}

export const getImageHashFromImgurImage = (
image: ImgurImage,
image: Partial<ImgurImage>,
cache?: typeof TinyCache
): string => {
return getImageHashFromText(image.link, cache)
Expand Down
1 change: 1 addition & 0 deletions src/imgur/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { deleteTag } from './deleteTag'
export { deleteTags } from './deleteTags'
export { getTags } from './getTags'
export { getPlayers } from './getPlayers'
export { updateTag } from './updateTag'
Expand Down
10 changes: 0 additions & 10 deletions src/sanity/getTagSlug.ts

This file was deleted.

19 changes: 0 additions & 19 deletions test/src/biketag/deleteTag.test.ts

This file was deleted.

19 changes: 0 additions & 19 deletions test/src/biketag/favoriteImage.test.ts

This file was deleted.

23 changes: 0 additions & 23 deletions test/src/biketag/getTag.test.ts

This file was deleted.

23 changes: 0 additions & 23 deletions test/src/biketag/getTagImage.test.ts

This file was deleted.

27 changes: 27 additions & 0 deletions test/src/biketag/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
describe('biketag.data()', () => {
test.todo('BikeTagClient provides BikeTag adapter from Credentials')

test.todo(
'BikeTagClient can ready BikeTag api when passed valid ImgurCredentials'
)

test.todo(
'BikeTagClient throws Errors.NotImplemented when game interface is invoked using BikeTag as a source'
)

test.todo(
'BikeTagClient throws Errors.NotImplemented when ambassadors interface is invoked using BikeTag as a source'
)

test.todo(
'BikeTagClient throws Errors.NotImplemented when settings interface is invoked using BikeTag as a source'
)

test.todo(
'BikeTagClient throws Errors.NotImplemented when tags interface is invoked using BikeTag as a source'
)

test.todo(
'BikeTagClient throws Errors.NotImplemented when players interface is invoked using BikeTag as a source'
)
})
Loading

0 comments on commit 1a7a17f

Please sign in to comment.