Files
wekan/server/lib/tests/customNumberFormat.tests.js
T
Lauri Ojansivu 23c81e0b6c Tests drive the code the app runs, not copies of it nothing loads.
Ten modules were reached only from tests. Some were copies of production
logic kept beside it, so a test passed whatever production did; the rest
were re-export files that only tests imported.

Copies removed, the test now reading what runs:
- models/lib/oauth2ClientSecretJwt.js: wekan-oidc ran its own vendored copy.
  The package file is now the only one and tests/oauth2ClientSecretJwt
  drives it; tests/packageAppImportBoundary fails if a second copy returns.
- models/lib/scrollbarCss.js (#5439): tests/scrollbarCss reads the rules in
  client/components/lists/list.css.
- models/lib/createListParams.js: tests/createListParams reads the check()
  pattern of createListAfter in server/models/lists.js and runs it by the
  rules of Meteor's check, so changing the server pattern fails the test.
- server/lib/cardMatch.js (#5910): the search is a Mongo selector in
  server/publications/cards.js, which tests/boardSearchComments now reads.
- server/lib/dueDateEdits.js (#6081): Cards.getDueDateChangeCount() counts
  the a-dueAt activities itself.

Helpers that production now calls:
- models/lib/checklistHide.js (was server/lib): the Checklists helpers
  hideCheckedState() and isItemHidden() call it, with the same strict
  "checked is true" rule as before.
- models/lib/subtaskSettings.js (was server/lib): the Board Settings
  subtask pickers mark the selected board and list with it.
  resolveSubtaskLanding(), which nothing called, is removed with its tests.

Re-export files removed, the tests importing the real module:
server/lib/listColors.js, cardScope.js, announcementVisibility.js,
customNumberFormat.js and subtaskHelpers.js.

docs/DeveloperDocs/Directory-Structure.md pointed at the migrations/
directory, which no longer exists; it now names server/migrations.

Thanks to xet7 !
2026-11-21 18:17:53 +02:00

42 lines
1.3 KiB
JavaScript

/* eslint-env mocha */
import { expect } from 'chai';
import { formatNumberValue } from '/imports/lib/customNumberFormat';
/**
* Unit tests for custom-field number formatting (#2091).
*
* "Custom number field displays as NaN if set blank after already being set":
* once a number Custom Field is given a value and then cleared, the blank /
* non-numeric value must render as an empty string rather than "NaN".
*/
describe('custom number field formatting (#2091)', function() {
it('renders an empty string for blank input', function() {
expect(formatNumberValue('')).to.equal('');
});
it('renders an empty string for null', function() {
expect(formatNumberValue(null)).to.equal('');
});
it('renders an empty string for undefined', function() {
expect(formatNumberValue(undefined)).to.equal('');
});
it('renders an empty string for non-numeric text (never "NaN")', function() {
expect(formatNumberValue('abc')).to.equal('');
expect(formatNumberValue(NaN)).to.equal('');
});
it('renders zero as "0"', function() {
expect(formatNumberValue(0)).to.equal('0');
});
it('renders a decimal number unchanged', function() {
expect(formatNumberValue(12.5)).to.equal('12.5');
});
it('accepts numeric strings', function() {
expect(formatNumberValue('42')).to.equal('42');
});
});