mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Rename richtext controller and write specs
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @jest-environment jsdom
|
||||
*/
|
||||
|
||||
import { Application } from "stimulus";
|
||||
import add_blank_to_link_controller from "../../../app/webpacker/controllers/add_blank_to_link_controller";
|
||||
|
||||
describe("AddBlankToLink", () => {
|
||||
beforeAll(() => {
|
||||
const application = Application.start();
|
||||
application.register("add-blank-to-link", add_blank_to_link_controller);
|
||||
});
|
||||
|
||||
describe("#add-blank-to-link", () => {
|
||||
beforeEach(() => {
|
||||
document.body.innerHTML = `<div data-controller="add-blank-to-link"><a href="www.ofn.com">www.ofn.com</a></div>`;
|
||||
});
|
||||
|
||||
it("adds target='_blank' to anchor tags", () => {
|
||||
const anchorTag = document.querySelector('a')
|
||||
expect(anchorTag.getAttribute('target')).toBe("_blank");
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user