Sha256: 5ef978c34f2ebb4ec3f93d12f1bf7b1626fe3e89ecd084f96609cca50e2bfe4b

Contents?: true

Size: 1019 Bytes

Versions: 17

Compression:

Stored size: 1019 Bytes

Contents

import { describe, it, expect } from "vitest"
import { Link } from "./link"
import { Text } from "./text"

describe("Link", () => {
  it("returns empty string if no params", () => {
    expect(new Link("").render).toBe("<a href='' ></a>")
  })

  it("returns attributes and data attributes", () => {
    expect(new Link("#").add(new Text("")).render).toBe(`<a href='#' ></a>`)
  })

  it("returns attributes and data attributes with custom data attributes", () => {
    expect(new Link("#", { id: "1", data: { foo: "bar" } }).render).toBe(`<a href='#' id='1' data-foo='bar'></a>`)
    expect(new Link("#", { id: "1", data: { foo: "bar", baz: "qux" } }).render).toBe(`<a href='#' id='1' data-foo='bar' data-baz='qux'></a>`)
    expect(new Link("#", { id: "1", data: { foo: { baz: "qux", quux: "corge" } } }).render).toBe(`<a href='#' id='1' data-foo-baz='qux' data-foo-quux='corge'></a>`)
  })

  it("adds children", () => {
    expect(new Link("#").add(new Text("Hello")).render).toBe(`<a href='#' >Hello</a>`)
  })
})

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
clapton-0.0.17 lib/clapton/javascripts/src/components/link.spec.ts
clapton-0.0.16 lib/clapton/javascripts/src/components/link.spec.ts
clapton-0.0.15 lib/clapton/javascripts/src/components/link.spec.ts
clapton-0.0.14 lib/clapton/javascripts/src/components/link.spec.ts
clapton-0.0.13 lib/clapton/javascripts/src/components/link.spec.ts
clapton-0.0.12 lib/clapton/javascripts/src/components/link.spec.ts
clapton-0.0.11 lib/clapton/javascripts/src/components/link.spec.ts
clapton-0.0.10 lib/clapton/javascripts/src/components/link.spec.ts
clapton-0.0.9 lib/clapton/javascripts/src/components/link.spec.ts
clapton-0.0.8 lib/clapton/javascripts/src/components/link.spec.ts
clapton-0.0.7 lib/clapton/javascripts/src/components/link.spec.ts
clapton-0.0.6 lib/clapton/javascripts/src/components/link.spec.ts
clapton-0.0.5 lib/clapton/javascripts/src/components/link.spec.ts
clapton-0.0.4 lib/clapton/javascripts/src/components/link.spec.ts
clapton-0.0.3 lib/clapton/javascripts/src/components/link.spec.ts
clapton-0.0.2 lib/clapton/javascripts/src/components/link.spec.ts
clapton-0.0.1 lib/clapton/javascripts/src/components/link.spec.ts