Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update APA and MLA citation dates for a Work #322

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion components/Work/ActionsDialog/Cite.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { render, screen, within } from "@testing-library/react";

import WorkDialogCite from "@/components/Work/ActionsDialog/Cite";
import { WorkProvider } from "@/context/work-context";
import { sampleWork1 } from "@/mocks/sample-work1";
Expand All @@ -13,17 +14,19 @@ describe("WorkDialogCite", () => {
}
it("renders thumbnail column content", async () => {
setup();

const div = screen.getByTestId("actions-dialog-aside");

expect(within(div).getByAltText(`${sampleWork1.title}`));
expect(within(div).getByText(sampleWork1.work_type as string));
});

it("renders expected metadata content", () => {
const { ark, terms_of_use, title } = sampleWork1;

const metadataValues = [ark, terms_of_use, title];

setup();

const div = screen.getByTestId("metadata");

// <dt>s
Expand All @@ -47,6 +50,26 @@ describe("WorkDialogCite", () => {

it("renders copy links for all metadata", () => {
setup();

expect(screen.getAllByText(/copy/i).length).toEqual(7);
});

it("renders today's date (date accessed) in MLA and APA Formats", () => {
setup();

const div = screen.getByTestId("metadata");
const today = new Date().toDateString();

const apaFormatEl = within(div).getByText(
`University Archives, Northwestern University Libraries. (${today}). Hawking dental products in outdoor market, Cuernavaca, Mexico, Retrieved from http://localhost/items/c16029ff-d027-496a-98b7-6f259395a8f7`,
{ exact: false }
);
const mlaFormatEl = within(div).getByText(
`University Archives, Northwestern University Libraries. "Hawking dental products in outdoor market, Cuernavaca, Mexico", Jim Roberts Photographs, 1968-1972 ${today}. http://localhost/items/c16029ff-d027-496a-98b7-6f259395a8f7`,
{ exact: false }
);

expect(apaFormatEl).toBeVisible();
expect(mlaFormatEl).toBeVisible();
});
});
5 changes: 3 additions & 2 deletions components/Work/ActionsDialog/Cite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
ActionsDialogStyled,
Content,
} from "@/components/Work/ActionsDialog/ActionsDialog.styled";

import ActionsDialogAside from "@/components/Work/ActionsDialog/Aside";
import CopyText from "@/components/Shared/CopyText";
import { DefinitionListWrapper } from "@/components/Shared/DefinitionList.styled";
Expand Down Expand Up @@ -30,9 +31,9 @@ const WorkDialogCite: React.FC = () => {
const dateObj: Date = new Date(create_date);
const formattedDate = dateObj.toDateString();
const itemLink = `${window.location.origin}/items/${id}`;
const apaFormat = `${library_unit}, ${nul}. (${formattedDate}). ${title}, Retrieved from ${itemLink}`;
const apaFormat = `${library_unit}, ${nul}. (${today}). ${title}, Retrieved from ${itemLink}`;
const chicagoTurabianFormat = `${library_unit}, ${nul}. "${title}", ${collection_title} Accessed ${today}. ${itemLink}`;
const mlaFormat = `${library_unit}, ${nul}. "${title}", ${collection_title} ${formattedDate}. ${window.location.origin}/items/${id}`;
const mlaFormat = `${library_unit}, ${nul}. "${title}", ${collection_title} ${today}. ${window.location.origin}/items/${id}`;
const wikiCitation = `<ref name=NUL>{{cite web | url=${itemLink} | title= ${title} (${formattedDate}) }} |author=Digital Collections, ${nul} |accessdate=${today} |publisher=${nul}, ${library_unit}}}</ref>`;

const metadata = [
Expand Down
Loading