## API
-`htmlPage(pagePathLevel, ctx, options, main = [])`
+- `initContext(ctx)`
+- `htmlPage(pagePathLevel, ctx, options, main = [])`
+- `dateOrNot(date, otherwise)`
+- `dateFormat(date, pInf nInf, otherwise)`
+- `timeElement(date, options)`
+- `secondsToPeriod(seconds)`
+- `indented(intent, list)`
+- `UL(items, indent, attributes, itemAttributesGenerator)`
+- `OL(items, indent, attributes, itemAttributesGenerator)`
+- `LI(item, indent, attributes)`
### Context
- `ctx.notifications`
Lists of errors and notices to show at top of page, before main content.
+`initContext` will create the arrays.
### Options
const { lazy } = require('@squeep/lazy-property');
+
+/**
+ * Set up expected fields for how we handle error reporting
+ * and whatnot.
+ * @param {Object} ctx
+ */
+const initContext = (ctx) => {
+ ctx.errors = [];
+ ctx.notifications = [];
+}
+
/**
* Some fields may have values outside normal dates, handle them here.
* @param {Date} date
module.exports = {
+ initContext,
dateOrNot,
dateFormat,
timeElement,
options = {};
});
+ describe('initContext', function () {
+ it('covers', function () {
+ th.initContext(ctx);
+ assert(ctx.errors);
+ assert(ctx.notifications);
+ assert(Array.isArray(ctx.errors));
+ assert(Array.isArray(ctx.notifications));
+ });
+ }); // initContext
+
describe('dateOrNot', function () {
let date, otherwise;
beforeEach(function () {