/** * Character cells and labels in the viewer's payload. * * Two rules the recorded response fixes, both of which look like bugs from the * inside and are parity from the outside. */ const test = require('node:test') const assert = require('node:assert') const fs = require('node:fs') const path = require('node:path') const { seededEstate, runService } = require('./harness') function viewOf(estate, libds) { const body = JSON.parse( runService(estate, 'public/viewdata', { tableName: 'SASControlTable', rows: [{ LIBDS: libds, FILTER_RK: -1 }] }) ) assert.equal(body.sasjsAbort, undefined) return body } test('a character cell keeps a leading blank and loses only the padding', () => { const estate = seededEstate({ demo: false }) const table = { columns: [{ name: 'C', type: 'char', length: 10 }], rows: [{ C: ' ABC' }, { C: 'ABC ' }, { C: ' ' }] } fs.writeFileSync( path.join(estate.appDir, 'data', 'DC_JSLIB', 'mpe_x_cells.json'), JSON.stringify(table) ) const rows = viewOf(estate, 'DC_JSLIB.MPE_X_CELLS').viewdata // a leading blank is part of the value, and the viewer shows it assert.equal(rows[0].C, ' ABC') // trailing blanks are the width SAS pads to assert.equal(rows[1].C, 'ABC') // an all-blank cell is SAS missing assert.equal(rows[2].C, ' ') }) test('cols and $viewdata report the labels the estate reports', () => { // the recorded response has cols[].LABEL for DSN as the data dictionary's // business label and $viewdata.vars.DSN.label as the physical label - two // members, two answers, and the estate is the authority const body = viewOf(seededEstate({ demo: false }), 'DC_JSLIB.MPE_TABLES') const dsn = body.cols.find((c) => c.NAME === 'DSN') assert.equal(dsn.LABEL, 'Dataset Name to be edited') assert.equal(body.$viewdata.vars.DSN.label, 'DSN') })