#!/usr/bin/node //--------------------------------------------------------------------- var path = require('path') var test = require('ig-test') var serialize = require('ig-serialize') var parser = require('../parser').parser //--------------------------------------------------------------------- var PAGES = module.exports.PAGES = { '/blank': '', '/page': 'Page', '/async/page': Promise.resolve('Page'), '/includePage': '@include(/page)', } var P = module.exports.P = { __pages__: PAGES, __parser__: parser, path: '/', get basepath(){ return path.dirname(this.path ?? '') }, get raw(){ return this.__pages__[this.path] ?? '' }, get text(){ return this.__parser__.parse(this, this.raw, {}) }, get: function(p){ return { __proto__: P, path: path.resolve(this.path, p), } }, // XXX resolvePathVars: function(path){ return path }, } //--------------------------------------------------------------------- test.Setups({ empty: function(assert){ return { code: [ '', '' ] }}, // slot... slot_empty: function(assert){ return {code: [ '@slot(slot)', '@slot("slot")', '@slot(\'slot\')', '@slot(name=slot)', '@slot(name="slot")', '@slot(name=\'slot\')', '', '', '', '', '', '', '' ]} }, slot_value: function(assert){ return {code: [ '', '', '@slot(slot value)', '@slot(slot text=value)', 'value' ]} }, slot_fill: function(assert){ var ins = this.slot_value(assert).code.slice(0, -1) return {code: [ ...ins.map(function(e){ return e + '@slot(slot other)' }), ...ins.map(function(e){ return e + '' }), ...ins.map(function(e){ return e + 'other' }), 'other' ]} }, slot_fill_fill: function(assert){ var ins = this.slot_fill(assert).code.slice(0, -1) return {code: [ ...ins.map(function(e){ return e + '@slot(slot third)' }), ...ins.map(function(e){ return e + '' }), ...ins.map(function(e){ return e + 'third' }), 'third' ]} }, // nested... slot_nested: function(assert){ return {code: [ '[[ ]]@slot(slot.content value)', '[[ value ]]' ]} }, slot_nested_overwrite: function(assert){ return {code: [ '[[ ]]@slot(slot value)', 'value' ]} }, // nested-self... slot_nested_nested: function(assert){ return {code: [ '[[ ]]', '[[ ]]', 'value' ]} }, slot_nested_shown_nested: function(assert){ return {code: [ '[[ ]]', '[[ ]]' ]} }, // slot content... slot_content: function(assert){ return {code: [ '[[ ]]', '[[ ]]' ]} }, slot_content_multi: function(assert){ return {code: [ '[[ ]]', '[[ moo moo moo ]]' ]} }, slot_content_filled: function(assert){ var ins = this.slot_content(assert).code.slice(0, -1) return {code: [ ...ins.map(function(e){ return '' + e }), '[[ content ]]' ]} }, slot_content_content_filled: function(assert){ var ins = this.slot_content_filled(assert).code var res = ins.pop() return {code: [ ...ins.map(function(e){ return e +'(( ))' }), '(( '+ res +' ))' ]} }, slot_content_nested: function(assert){ return {code: [ 'moo[[ ]]', '[[ moo ]]' ]} }, /* XXX SHOWN_HIDDEN // XXX these need to be revised... // ...do we actually need hidden/shown??? // slot_shown: function(assert){ var ins = this.slot_value(assert).code var expect = ins.pop() return {code: [ ...ins.map(function(i){ return i +' @slot(slot that shown)' }), 'that that' ]} }, slot_hidden: function(assert){ return {code: [ '