lamed_table
Version:
Light table implementation
66 lines (57 loc) • 3.93 kB
JavaScript
// 'use strict' // Comment out in test functions
console.log(`Starting ${__filename}...`) // comment line to remove simple logging
// ------------------------------------------------------
// show.test.js
// Purpose: The purpose of this to test show.js
// Date Created: 2020/01/21
// Created by : Perez Lamed van Niekerk
// ------------------------------------------------------
/* jshint esversion: 6 */
const { TableDef } = require('../src/table') // eslint-disable-line
const { con, unZip, unThrow, isTestRunner } = require('lamed_test') // eslint-disable-line
// ---------------------------------------------------
// Setup unit test
const show = !isTestRunner()
if (show) {
con.traceSet(0) // Activate trace when not run from test runner
// con.useChalk(require('chalk')) // Give us some colour
}
con.logLine()
con.log(` --> ${__filename}`) // Show test case
// Setup table data --------------------------
function setupTable (show) {
// Create sample table
const result = new TableDef(
['Ticket #', 'Assigned/Close Group', 'Assignee', 'Open Date and Time', 'Last Modified Date', 'SLA', 'Summary', 'End User', 'Close Date and Time', 'value', 'month', 'week'], 'csv')
result.Rows.Add(['1', 'IT', 'Daan', '2019/01/02 10:47', '2019/01/02 10:59', 'OK', 'Lotus Notes bla bla', 'Daan', '2019/01/02 10:59', '10.5', 'Jan', 'week1'])
result.Rows.Add(['2', 'IT', 'Ben', '2019/01/03 7:11', '2019/01/03 7:13', 'OK', 'password reset', 'Piet', '2019/01/03 7:13', '12.5', 'Jan', 'week1']) // password
result.Rows.Add(['3', 'IT', 'Bobo', '2019/01/02 9:45', '2019/01/03 7:40', 'OK', 'Microsoft teams set up', 'Koos', '2019/01/03 7:40', '15.5', 'Jan', 'week1'])
result.Rows.Add(['4', 'IT', 'Bobo', '2019/01/03 6:32', '2019/01/03 7:41', 'OK', 'pin for the printer', 'Hennie', '2019/01/03 7:41', '14.1', 'Jan', 'week1']) // printer
result.Rows.Add(['5', 'IT', 'Bobo', '2019/01/02 9:51', '2019/01/03 7:41', 'OK', 'password reset', 'Neda', '2019/01/03 7:41', '17.4', 'Jan', 'week2']) // password
result.Rows.Add(['6', 'IT', 'Bobo', '2019/01/03 9:53', '2019/01/03 10:27', 'OK', '3G data reached', 'Aaron', '2019/01/03 10:27', '12.9', 'Jan', 'week2']) // 3G
result.Rows.Add(['7', 'IT', 'Bobo', '2019/01/03 12:15', '2019/01/03 13:54', 'OK', 'Lotus bla bla bla', 'Cele', '2019/01/03 13:54', '19', 'Feb', 'week2'])
result.Rows.Add(['8', 'IT', 'Bobo', '2019/01/03 9:14', '2019/01/04 6:40', 'OK', 'Re Access to print for', 'Emile', '2019/01/03 14:02', '13.3', 'Feb', 'week3']) // print
result.Rows.Add(['9', 'IT', 'Bobo', '2019/01/03 13:06', '2019/01/04 5:34', 'OK', '3G not working', 'Bettie', '2019/01/04 5:34', '18.4', 'Feb', 'week3']) // 3G
result.Rows.Add(['10', 'IT', 'Ben', '2019/01/03 8:37', '2019/01/04 6:11', 'OK', 'msTeams', 'Emile', '2019/01/04 6:11', '12.7', 'Feb', 'week3'])
result.Rows.Add(['11', 'IT', 'Daan', '2019/01/04 6:41', '2019/01/04 6:45', 'OK', 'Junk mail', 'Carl', '2019/01/04 6:45', '33', 'Feb', 'week3']) // mail
result.Rows.Add(['12', 'IT', 'Bobo', '2019/01/04 7:42', '2019/01/04 9:24', 'OK', 'EMAIL ISSUE', 'Slime', '2019/01/04 9:24', '35', 'Feb', 'week3']) // email
result.Rows.Add(['13', 'IT', 'Bobo', '2019/02/04 7:48', '2019/02/04 11:08', 'OK', 'phone not working', 'Baba', '2019/02/04 11:08', '45', 'Feb', 'week3'])
// result.stats(show, false)
unZip(() => result.DATA.cols.toString(), 'ticket #,assigned/close group,assignee,open date and time,last modified date,sla,summary,end user,close date and time,value,month')
return result
}
con.clear()
const myTable = setupTable(true)
myTable.show()
myTable.show(true, 10, 7)
// myTable.show()
myTable.show(true, 10, 7, 12)
myTable.stats(true, true)
myTable.seriesMonth(['assignee', 'sla'])
myTable.seriesWeek(['assignee', 'sla'])
// con.logHeading('trim')
// myTable.Rows.trim(5)
// myTable.show()
// ------------------------------------------------
con.logGreen(` √ ${__filename}`) // Success!!!
con.traceLine()