Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

788 B
Raw Blame
import { describe, expect, it } from 'vitest'
import { diffLines } from './line-diff'

describe('diffLines', () => {
  it('pairs unchanged lines and marks the rest', () => {
    expect(diffLines('a\nb\nc', 'a\nB\nc\nd')).toEqual([
      { kind: 'same', before: 'a', after: 'a' },
      { kind: 'changed', before: 'b', after: 'B' },
      { kind: 'same', before: 'c', after: 'c' },
      { kind: 'added', before: null, after: 'd' },
    ])
  })

  it('reports removed lines', () => {
    expect(diffLines('a\nb', 'a')).toEqual([
      { kind: 'same', before: 'a', after: 'a' },
      { kind: 'removed', before: 'b', after: null },
    ])
  })

  it('treats identical texts as unchanged', () => {
    expect(diffLines('x\ny', 'x\ny').every((row) => row.kind === 'same')).toBe(true)
  })
})