Skip to content

Commit

Permalink
chore: improve method name
Browse files Browse the repository at this point in the history
  • Loading branch information
hoeppner-dataport committed Nov 6, 2023
1 parent 00c6071 commit bc675d6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe("LinkContentElement", () => {
const component = wrapper.getComponent(LinkContentElementCreate);
component.vm.$emit("create:url", "https://abc.de");

expect(useMetaTagExtractorApiMock.getData).toHaveBeenCalled();
expect(useMetaTagExtractorApiMock.extractMetaTags).toHaveBeenCalled();
});

describe("when no protocol was provided", () => {
Expand All @@ -135,7 +135,7 @@ describe("LinkContentElement", () => {
component.vm.$emit("create:url", url);

const expected = `https://${url}`;
expect(useMetaTagExtractorApiMock.getData).toHaveBeenCalledWith(
expect(useMetaTagExtractorApiMock.extractMetaTags).toHaveBeenCalledWith(
expected
);
});
Expand All @@ -153,7 +153,9 @@ describe("LinkContentElement", () => {
imageUrl: "https://abc.de/foto.png",
};

useMetaTagExtractorApiMock.getData.mockResolvedValue(fakeMetaTags);
useMetaTagExtractorApiMock.extractMetaTags.mockResolvedValue(
fakeMetaTags
);

const component = wrapper.getComponent(LinkContentElementCreate);
component.vm.$emit("create:url", url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default defineComponent({
() => props.isEditMode && !computedElement.value.content.url
);
const { getData } = useMetaTagExtractorApi();
const { extractMetaTags } = useMetaTagExtractorApi();
const { createPreviewImage } = usePreviewGenerator(element.value.id);
Expand All @@ -100,7 +100,7 @@ export default defineComponent({
const validUrl = ensureProtocolIncluded(originalUrl);
modelValue.value.url = validUrl;
const { title, description, imageUrl } = await getData(validUrl);
const { title, description, imageUrl } = await extractMetaTags(validUrl);
modelValue.value.title = title;
modelValue.value.description = description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type MetaTagResult = {
export const useMetaTagExtractorApi = () => {
const metaTagApi = MetaTagExtractorApiFactory(undefined, "/v3", $axios);

const getData = async (url: string): Promise<MetaTagResult> => {
const extractMetaTags = async (url: string): Promise<MetaTagResult> => {
try {
const res = await metaTagApi.metaTagExtractorControllerGetData({
url,
Expand All @@ -28,6 +28,6 @@ export const useMetaTagExtractorApi = () => {
};

return {
getData,
extractMetaTags,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe("useMetaTagExtractorApi", () => {
return { wrapper, composable };
};

describe("getData", () => {
describe("extractMetaTags", () => {
describe("when meta tags could be extracted", () => {
const setup = () => {
const mockedResponse: MetaTagExtractorResponse = {
Expand All @@ -59,14 +59,14 @@ describe("useMetaTagExtractorApi", () => {
it("should be defined", () => {
const { composable } = setup();

expect(composable?.getData).toBeDefined();
expect(composable?.extractMetaTags).toBeDefined();
});

it("should return the data", async () => {
const { composable, mockedResponse } = setup();

const url = "https://test.de/my-article";
const data = await composable?.getData(url);
const data = await composable?.extractMetaTags(url);

expect(data).toEqual(mockedResponse);
});
Expand Down Expand Up @@ -96,7 +96,7 @@ describe("useMetaTagExtractorApi", () => {
const { composable } = setup();

const url = "https://test.de/my-article";
const data = await composable?.getData(url);
const data = await composable?.extractMetaTags(url);

expect(data).toEqual({ url, title: "", description: "" });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("usePreviewGenerator", () => {
return { wrapper, composable };
};

describe("getData", () => {
describe("createPreviewImage", () => {
describe("when meta tags could be extracted", () => {
const setup = () => {
const elementId = "my-custom-mocked-id";
Expand Down

0 comments on commit bc675d6

Please sign in to comment.