all repos — snow-editor @ 65993a713586363acceab129af67161a5fbe71cc

small and cozy markdown, and orgmode editor

src/lib/org/editorUtils.test.js (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
import assert from 'node:assert';
import { describe, test } from 'node:test';
import {
  adjustHeading,
  isChecklistLine,
  toggleChecklistLine,
} from './editorUtils.js';

describe('Org editor utils', () => {
  test('toggleChecklistLine switches states', () => {
    assert.equal(toggleChecklistLine('- [ ] task'), '- [X] task');
    assert.equal(toggleChecklistLine('- [X] task'), '- [ ] task');
    assert.ok(isChecklistLine('- [ ] task'));
  });

  test('adjustHeading changes star count', () => {
    assert.equal(adjustHeading('* Title', 1), '** Title');
    assert.equal(adjustHeading('** Title', -1), '* Title');
  });
});