diff --git a/test/parameter_hunter_tests.js b/test/parameter_hunter_tests.js index 7db9ec85d..092f44428 100644 --- a/test/parameter_hunter_tests.js +++ b/test/parameter_hunter_tests.js @@ -1,350 +1,345 @@ -(function () { - "use strict"; - - var ph = require('../core/lib/parameter_hunter'); - - //setup current pattern from what we would have during execution - function currentPatternClosure() { - return { - "relPath": "02-organisms/02-comments/01-sticky-comment.mustache", - "fileName": "01-sticky-comment", - "subdir": "02-organisms/02-comments", - "name": "02-organisms-02-comments-01-sticky-comment", - "patternBaseName": "sticky-comment", - "patternLink": "02-organisms-02-comments-01-sticky-comment/02-organisms-02-comments-01-sticky-comment.html", - "patternGroup": "organisms", - "patternSubGroup": "comments", - "flatPatternPath": "02-organisms-02-comments", - "patternPartial": "organisms-sticky-comment", - "template": "{{> molecules-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}", - "extendedTemplate": "{{> molecules-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}", - "parameteredPartials": [ - "{{> molecules-single-comment(description: 'We are all in the gutter, but some of us are looking at the stars.') }}", - "{{> molecules-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}" - ] - }; - } - - function patternlabClosure() { - return { - patterns: [ - { - "relPath": "01-molecules/06-components/02-single-comment.mustache", - "fileName": "02-single-comment", - "subdir": "01-molecules/06-components", - "name": "01-molecules-06-components-02-single-comment", - "patternBaseName": "single-comment", - "patternLink": "01-molecules-06-components-02-single-comment/01-molecules-06-components-02-single-comment.html", - "patternGroup": "molecules", - "patternSubGroup": "components", - "flatPatternPath": "01-molecules-06-components", - "patternPartial": "molecules-single-comment", - "template": "
{{description}}
", - "extendedTemplate": "{{description}}
" - } - ], - config: { - debug: false - }, - data: { - description: 'Not a quote from a smart man' - }, - partials: {} - } +"use strict"; + +var tap = require('tap'); + +var ph = require('../core/lib/parameter_hunter'); + +//setup current pattern from what we would have during execution +function currentPatternClosure() { + return { + "relPath": "02-organisms/02-comments/01-sticky-comment.mustache", + "fileName": "01-sticky-comment", + "subdir": "02-organisms/02-comments", + "name": "02-organisms-02-comments-01-sticky-comment", + "patternBaseName": "sticky-comment", + "patternLink": "02-organisms-02-comments-01-sticky-comment/02-organisms-02-comments-01-sticky-comment.html", + "patternGroup": "organisms", + "patternSubGroup": "comments", + "flatPatternPath": "02-organisms-02-comments", + "patternPartial": "organisms-sticky-comment", + "template": "{{> molecules-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}", + "extendedTemplate": "{{> molecules-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}", + "parameteredPartials": [ + "{{> molecules-single-comment(description: 'We are all in the gutter, but some of us are looking at the stars.') }}", + "{{> molecules-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}" + ] }; - - exports['parameter_hunter'] = { - 'parameter hunter finds and extends templates' : function(test){ - var currentPattern = currentPatternClosure(); - var patternlab = patternlabClosure(); - var parameter_hunter = new ph(); - - parameter_hunter.find_parameters(currentPattern, patternlab); - test.equals(currentPattern.extendedTemplate, 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.
'); - - test.done(); +} + +function patternlabClosure() { + return { + patterns: [ + { + "relPath": "01-molecules/06-components/02-single-comment.mustache", + "fileName": "02-single-comment", + "subdir": "01-molecules/06-components", + "name": "01-molecules-06-components-02-single-comment", + "patternBaseName": "single-comment", + "patternLink": "01-molecules-06-components-02-single-comment/01-molecules-06-components-02-single-comment.html", + "patternGroup": "molecules", + "patternSubGroup": "components", + "flatPatternPath": "01-molecules-06-components", + "patternPartial": "molecules-single-comment", + "template": "{{description}}
", + "extendedTemplate": "{{description}}
" + } + ], + config: { + debug: false + }, + data: { + description: 'Not a quote from a smart man' }, + partials: {} + } +}; - 'parameter hunter finds and extends templates with mixed parameter and global data' : function(test){ - var currentPattern = currentPatternClosure(); - var patternlab = patternlabClosure(); - var parameter_hunter = new ph(); +tap.test('parameter hunter finds and extends templates', function(test) { + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); - patternlab.patterns[0].template = "{{description}}
"; - patternlab.patterns[0].extendedTemplate = patternlab.patterns[0].template; - patternlab.data.foo = 'Bar'; - patternlab.data.description = 'Baz'; + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.
'); - parameter_hunter.find_parameters(currentPattern, patternlab); - test.equals(currentPattern.extendedTemplate, 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.
'); + test.end(); +}); - test.done(); - }, +tap.test('parameter hunter finds and extends templates with mixed parameter and global data', function(test) { + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); - 'parameter hunter finds and extends templates with verbose partials' : function(test){ - var currentPattern = currentPatternClosure(); - var patternlab = patternlabClosure(); - var parameter_hunter = new ph(); + patternlab.patterns[0].template = "{{description}}
"; + patternlab.patterns[0].extendedTemplate = patternlab.patterns[0].template; + patternlab.data.foo = 'Bar'; + patternlab.data.description = 'Baz'; - currentPattern.template = "{{> 01-molecules/06-components/02-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}"; - currentPattern.extendedTemplate = currentPattern.template; - currentPattern.parameteredPartials[0] = "{{> 01-molecules/06-components/02-single-comment(description: 'We are all in the gutter, but some of us are looking at the stars.') }}"; - currentPattern.parameteredPartials[1] = currentPattern.template; + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.
'); - parameter_hunter.find_parameters(currentPattern, patternlab); - test.equals(currentPattern.extendedTemplate, 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.
'); + test.end(); +}); - test.done(); - }, +tap.test('parameter hunter finds and extends templates with verbose partials', function(test) { + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); - 'parameter hunter finds and extends templates with fully-pathed partials' : function(test){ - var currentPattern = currentPatternClosure(); - var patternlab = patternlabClosure(); - var parameter_hunter = new ph(); + currentPattern.template = "{{> 01-molecules/06-components/02-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = "{{> 01-molecules/06-components/02-single-comment(description: 'We are all in the gutter, but some of us are looking at the stars.') }}"; + currentPattern.parameteredPartials[1] = currentPattern.template; - currentPattern.template = "{{> 01-molecules/06-components/02-single-comment.mustache(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}"; - currentPattern.extendedTemplate = currentPattern.template; - currentPattern.parameteredPartials[0] = "{{> 01-molecules/06-components/02-single-comment.mustache(description: 'We are all in the gutter, but some of us are looking at the stars.') }}"; - currentPattern.parameteredPartials[1] = currentPattern.template; + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.
'); - parameter_hunter.find_parameters(currentPattern, patternlab); - test.equals(currentPattern.extendedTemplate, 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.
'); + test.end(); +}); - test.done(); - }, +tap.test('parameter hunter finds and extends templates with fully-pathed partials', function(test) { + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); - //previous tests were for unquoted parameter keys and single-quoted values. - //test other quoting options. - 'parameter hunter parses parameters with unquoted keys and unquoted values' : function(test){ - var currentPattern = currentPatternClosure(); - var patternlab = patternlabClosure(); - var parameter_hunter = new ph(); + currentPattern.template = "{{> 01-molecules/06-components/02-single-comment.mustache(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = "{{> 01-molecules/06-components/02-single-comment.mustache(description: 'We are all in the gutter, but some of us are looking at the stars.') }}"; + currentPattern.parameteredPartials[1] = currentPattern.template; - currentPattern.template = "{{> molecules-single-comment(description: true) }}"; - currentPattern.extendedTemplate = currentPattern.template; - currentPattern.parameteredPartials[0] = currentPattern.template; + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.
'); - parameter_hunter.find_parameters(currentPattern, patternlab); - test.equals(currentPattern.extendedTemplate, 'true
'); + test.end(); +}); - test.done(); - }, +//previous tests were for unquoted parameter keys and single-quoted values. +//test other quoting options. +tap.test('parameter hunter parses parameters with unquoted keys and unquoted values', function(test) { + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); - 'parameter hunter parses parameters with unquoted keys and double-quoted values' : function(test){ - var currentPattern = currentPatternClosure(); - var patternlab = patternlabClosure(); - var parameter_hunter = new ph(); + currentPattern.template = "{{> molecules-single-comment(description: true) }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; - currentPattern.template = "{{> molecules-single-comment(description: \"true\") }}"; - currentPattern.extendedTemplate = currentPattern.template; - currentPattern.parameteredPartials[0] = currentPattern.template; + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, 'true
'); - parameter_hunter.find_parameters(currentPattern, patternlab); - test.equals(currentPattern.extendedTemplate, 'true
'); + test.end(); +}); - test.done(); - }, +tap.test('parameter hunter parses parameters with unquoted keys and double-quoted values', function(test) { + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); - 'parameter hunter parses parameters with single-quoted keys and unquoted values' : function(test){ - var currentPattern = currentPatternClosure(); - var patternlab = patternlabClosure(); - var parameter_hunter = new ph(); + currentPattern.template = "{{> molecules-single-comment(description: \"true\") }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; - currentPattern.template = "{{> molecules-single-comment('description': true) }}"; - currentPattern.extendedTemplate = currentPattern.template; - currentPattern.parameteredPartials[0] = currentPattern.template; + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, 'true
'); - parameter_hunter.find_parameters(currentPattern, patternlab); - test.equals(currentPattern.extendedTemplate, 'true
'); + test.end(); +}); - test.done(); - }, +tap.test('parameter hunter parses parameters with single-quoted keys and unquoted values', function(test) { + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); - 'parameter hunter parses parameters with single-quoted keys and single-quoted values wrapping internal escaped single-quotes' : function(test){ - var currentPattern = currentPatternClosure(); - var patternlab = patternlabClosure(); - var parameter_hunter = new ph(); + currentPattern.template = "{{> molecules-single-comment('description': true) }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; - currentPattern.template = "{{> molecules-single-comment('description': 'true not,\\'true\\'') }}"; - currentPattern.extendedTemplate = currentPattern.template; - currentPattern.parameteredPartials[0] = currentPattern.template; + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, 'true
'); - parameter_hunter.find_parameters(currentPattern, patternlab); - test.equals(currentPattern.extendedTemplate, 'true not,'true'
'); + test.end(); +}); - test.done(); - }, +tap.test('parameter hunter parses parameters with single-quoted keys and single-quoted values wrapping internal escaped single-quotes', function(test) { + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); - 'parameter hunter parses parameters with single-quoted keys and double-quoted values wrapping internal single-quotes' : function(test){ - var currentPattern = currentPatternClosure(); - var patternlab = patternlabClosure(); - var parameter_hunter = new ph(); + currentPattern.template = "{{> molecules-single-comment('description': 'true not,\\'true\\'') }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; - currentPattern.template = "{{> molecules-single-comment('description': \"true not:'true'\") }}"; - currentPattern.extendedTemplate = currentPattern.template; - currentPattern.parameteredPartials[0] = currentPattern.template; + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, 'true not,'true'
'); - parameter_hunter.find_parameters(currentPattern, patternlab); - test.equals(currentPattern.extendedTemplate, 'true not:'true'
'); + test.end(); +}); - test.done(); - }, +tap.test('parameter hunter parses parameters with single-quoted keys and double-quoted values wrapping internal single-quotes', function(test) { + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); - 'parameter hunter parses parameters with double-unquoted keys and unquoted values' : function(test){ - var currentPattern = currentPatternClosure(); - var patternlab = patternlabClosure(); - var parameter_hunter = new ph(); + currentPattern.template = "{{> molecules-single-comment('description': \"true not:'true'\") }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; - currentPattern.template = "{{> molecules-single-comment(\"description\": true) }}"; - currentPattern.extendedTemplate = currentPattern.template; - currentPattern.parameteredPartials[0] = currentPattern.template; + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, 'true not:'true'
'); - parameter_hunter.find_parameters(currentPattern, patternlab); - test.equals(currentPattern.extendedTemplate, 'true
'); + test.end(); +}); - test.done(); - }, +tap.test('parameter hunter parses parameters with double-unquoted keys and unquoted values', function(test) { + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); - 'parameter hunter parses parameters with double-quoted keys and single-quoted values wrapping internal double-quotes' : function(test){ - var currentPattern = currentPatternClosure(); - var patternlab = patternlabClosure(); - var parameter_hunter = new ph(); + currentPattern.template = "{{> molecules-single-comment(\"description\": true) }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; - currentPattern.template = "{{> molecules-single-comment(\"description\": 'true not{\"true\"') }}"; - currentPattern.extendedTemplate = currentPattern.template; - currentPattern.parameteredPartials[0] = currentPattern.template; + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, 'true
'); - parameter_hunter.find_parameters(currentPattern, patternlab); - test.equals(currentPattern.extendedTemplate, 'true not{"true"
'); + test.end(); +}); - test.done(); - }, +tap.test('parameter hunter parses parameters with double-quoted keys and single-quoted values wrapping internal double-quotes', function(test) { + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); - 'parameter hunter parses parameters with double-quoted keys and double-quoted values wrapping internal escaped double-quotes' : function(test){ - var currentPattern = currentPatternClosure(); - var patternlab = patternlabClosure(); - var parameter_hunter = new ph(); + currentPattern.template = "{{> molecules-single-comment(\"description\": 'true not{\"true\"') }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; - currentPattern.template = "{{> molecules-single-comment(\"description\": \"true not}\\\"true\\\"\") }}"; - currentPattern.extendedTemplate = currentPattern.template; - currentPattern.parameteredPartials[0] = currentPattern.template; + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, 'true not{"true"
'); - parameter_hunter.find_parameters(currentPattern, patternlab); - test.equals(currentPattern.extendedTemplate, 'true not}"true"
'); + test.end(); +}); - test.done(); - }, +tap.test('parameter hunter parses parameters with double-quoted keys and double-quoted values wrapping internal escaped double-quotes', function(test) { + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); - 'parameter hunter parses parameters with combination of quoting schemes for keys and values' : function(test){ - var currentPattern = currentPatternClosure(); - var patternlab = patternlabClosure(); - var parameter_hunter = new ph(); + currentPattern.template = "{{> molecules-single-comment(\"description\": \"true not}\\\"true\\\"\") }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; - currentPattern.template = "{{> molecules-single-comment(description: true, 'foo': false, \"bar\": false, 'single': true, 'singlesingle': 'true', 'singledouble': \"true\", \"double\": true, \"doublesingle\": 'true', \"doubledouble\": \"true\") }}"; - currentPattern.extendedTemplate = currentPattern.template; - currentPattern.parameteredPartials[0] = currentPattern.template; + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, 'true not}"true"
'); - parameter_hunter.find_parameters(currentPattern, patternlab); - test.equals(currentPattern.extendedTemplate, 'true
'); + test.end(); +}); - test.done(); - }, +tap.test('parameter hunter parses parameters with combination of quoting schemes for keys and values', function(test) { + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); - 'parameter hunter parses parameters with values containing a closing parenthesis' : function(test){ - // From issue #291 https://github.com/pattern-lab/patternlab-node/issues/291 - var currentPattern = currentPatternClosure(); - var patternlab = patternlabClosure(); - var parameter_hunter = new ph(); + currentPattern.template = "{{> molecules-single-comment(description: true, 'foo': false, \"bar\": false, 'single': true, 'singlesingle': 'true', 'singledouble': \"true\", \"double\": true, \"doublesingle\": 'true', \"doubledouble\": \"true\") }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; - currentPattern.template = "{{> molecules-single-comment(description: 'Hello ) World') }}"; - currentPattern.extendedTemplate = currentPattern.template; - currentPattern.parameteredPartials[0] = currentPattern.template; + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, 'true
'); - parameter_hunter.find_parameters(currentPattern, patternlab); - test.equals(currentPattern.extendedTemplate, 'Hello ) World
'); + test.end(); +}); - test.done(); - }, +tap.test('parameter hunter parses parameters with values containing a closing parenthesis', function(test) { + // From issue #291 https://github.com/pattern-lab/patternlab-node/issues/291 + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); - 'parameter hunter parses parameters that follow a non-quoted value' : function(test){ - // From issue #291 https://github.com/pattern-lab/patternlab-node/issues/291 - var currentPattern = currentPatternClosure(); - var patternlab = patternlabClosure(); - var parameter_hunter = new ph(); + currentPattern.template = "{{> molecules-single-comment(description: 'Hello ) World') }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; - patternlab.patterns[0].template = "{{foo}}
{{bar}}
"; - patternlab.patterns[0].extendedTemplate = patternlab.patterns[0].template; + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, 'Hello ) World
'); - currentPattern.template = "{{> molecules-single-comment(foo: true, bar: \"Hello World\") }}"; - currentPattern.extendedTemplate = currentPattern.template; - currentPattern.parameteredPartials[0] = currentPattern.template; + test.end(); +}); - parameter_hunter.find_parameters(currentPattern, patternlab); - test.equals(currentPattern.extendedTemplate, 'true
Hello World
'); +tap.test('parameter hunter parses parameters that follow a non-quoted value', function(test) { + // From issue #291 https://github.com/pattern-lab/patternlab-node/issues/291 + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); - test.done(); - }, + patternlab.patterns[0].template = "{{foo}}
{{bar}}
"; + patternlab.patterns[0].extendedTemplate = patternlab.patterns[0].template; - 'parameter hunter parses parameters whose keys contain escaped quotes' : function(test){ - // From issue #291 https://github.com/pattern-lab/patternlab-node/issues/291 - var currentPattern = currentPatternClosure(); - var patternlab = patternlabClosure(); - var parameter_hunter = new ph(); + currentPattern.template = "{{> molecules-single-comment(foo: true, bar: \"Hello World\") }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; - patternlab.patterns[0].template = "{{ silly'key }}
{{bar}}
{{ another\"silly-key }}
"; - patternlab.patterns[0].extendedTemplate = patternlab.patterns[0].template; + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, 'true
Hello World
'); - currentPattern.template = "{{> molecules-single-comment('silly\\\'key': true, bar: \"Hello World\", \"another\\\"silly-key\": 42 ) }}"; - currentPattern.extendedTemplate = currentPattern.template; - currentPattern.parameteredPartials[0] = currentPattern.template; + test.end(); +}); - parameter_hunter.find_parameters(currentPattern, patternlab); - test.equals(currentPattern.extendedTemplate, 'true
Hello World
42
'); +tap.test('parameter hunter parses parameters whose keys contain escaped quotes', function(test) { + // From issue #291 https://github.com/pattern-lab/patternlab-node/issues/291 + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); - test.done(); - }, + patternlab.patterns[0].template = "{{ silly'key }}
{{bar}}
{{ another\"silly-key }}
"; + patternlab.patterns[0].extendedTemplate = patternlab.patterns[0].template; - 'parameter hunter skips malformed parameters' : function(test){ - // From issue #291 https://github.com/pattern-lab/patternlab-node/issues/291 - var currentPattern = currentPatternClosure(); - var patternlab = patternlabClosure(); - var parameter_hunter = new ph(); + currentPattern.template = "{{> molecules-single-comment('silly\\\'key': true, bar: \"Hello World\", \"another\\\"silly-key\": 42 ) }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; - patternlab.patterns[0].template = "{{foo}}
"; - patternlab.patterns[0].extendedTemplate = patternlab.patterns[0].template; + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, 'true
Hello World
42
'); - currentPattern.abspath = __filename; - currentPattern.template = "{{> molecules-single-comment( missing-val: , : missing-key, : , , foo: \"Hello World\") }}"; - currentPattern.extendedTemplate = currentPattern.template; - currentPattern.parameteredPartials[0] = currentPattern.template; + test.end(); +}); - console.log('\nPattern Lab should catch JSON.parse() errors and output useful debugging information...'); - parameter_hunter.find_parameters(currentPattern, patternlab); - test.equals(currentPattern.extendedTemplate, ''); +tap.test('parameter hunter skips malformed parameters', function(test) { + // From issue #291 https://github.com/pattern-lab/patternlab-node/issues/291 + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); - test.done(); - }, + patternlab.patterns[0].template = "{{foo}}
"; + patternlab.patterns[0].extendedTemplate = patternlab.patterns[0].template; - 'parameter hunter parses parameters containing html tags' : function(test){ - // From issue #145 https://github.com/pattern-lab/patternlab-node/issues/145 - var currentPattern = currentPatternClosure(); - var patternlab = patternlabClosure(); - var parameter_hunter = new ph(); + currentPattern.abspath = __filename; + currentPattern.template = "{{> molecules-single-comment( missing-val: , : missing-key, : , , foo: \"Hello World\") }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; - patternlab.patterns[0].template = "{{{ tag1 }}}
{{{ tag2 }}}
{{{ tag3 }}}
"; - patternlab.patterns[0].extendedTemplate = patternlab.patterns[0].template; + console.log('\nPattern Lab should catch JSON.parse() errors and output useful debugging information...'); + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, ''); - currentPattern.template = "{{> molecules-single-comment(tag1: 'Single-quoted', tag2: \"Double-quoted\", tag3: 'With attributes') }}"; - currentPattern.extendedTemplate = currentPattern.template; - currentPattern.parameteredPartials[0] = currentPattern.template; + test.end(); +}); - parameter_hunter.find_parameters(currentPattern, patternlab); - test.equals(currentPattern.extendedTemplate, 'Single-quoted
Double-quoted
With attributes
'); +tap.test('parameter hunter parses parameters containing html tags', function(test){ + // From issue #145 https://github.com/pattern-lab/patternlab-node/issues/145 + var currentPattern = currentPatternClosure(); + var patternlab = patternlabClosure(); + var parameter_hunter = new ph(); - test.done(); - } + patternlab.patterns[0].template = "{{{ tag1 }}}
{{{ tag2 }}}
{{{ tag3 }}}
"; + patternlab.patterns[0].extendedTemplate = patternlab.patterns[0].template; + currentPattern.template = "{{> molecules-single-comment(tag1: 'Single-quoted', tag2: \"Double-quoted\", tag3: 'With attributes') }}"; + currentPattern.extendedTemplate = currentPattern.template; + currentPattern.parameteredPartials[0] = currentPattern.template; - }; + parameter_hunter.find_parameters(currentPattern, patternlab); + test.equals(currentPattern.extendedTemplate, 'Single-quoted
Double-quoted
With attributes
'); -}()); + test.end(); +});