From 2d999acc76d166dac55ff97516344f8eca58b564 Mon Sep 17 00:00:00 2001 From: LarsHassler Date: Fri, 27 Oct 2017 16:38:44 +0200 Subject: [PATCH 1/3] docs(Configuration): added documentation for caseSensitive option --- docs/Configuration.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/Configuration.md b/docs/Configuration.md index 70d4344..7890a61 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -131,6 +131,17 @@ number of [pattern specific configuration](#pattern-specific-configuration). } ``` +#### caseSensitive (default: true) + +Depending on the patternlab version, the headline is sometimes with real +capitalization and sometimes just done with css. Which means if you switch it might +introduce problems. By default patternlab-to-gemini is case-sensitive. With +this config option it can be disabled. + +```json +"caseSensitive": false +``` + #### templateFile (default: ./templates/main.js) The path to the file where the templates for the tests. From 3642444a3ebb663fc3058c23622339110bba7601 Mon Sep 17 00:00:00 2001 From: LarsHassler Date: Fri, 27 Oct 2017 17:43:39 +0200 Subject: [PATCH 2/3] feat(main): added caseSensitive option --- src/main.js | 3 ++- test/main.js | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index 736a256..5e47871 100644 --- a/src/main.js +++ b/src/main.js @@ -73,6 +73,7 @@ var PatternlabToNode = function(options) { defaultSizes: null, loadOnSinglePage: false, groupTestsByType: false, + caseSensitive: true, patterns: null }, settings); @@ -232,7 +233,7 @@ PatternlabToNode.prototype.scrapePatternlab_ = function(html) { if (!shouldBeExcluded) { patterns.push({ id: patternId, - name: header, + name: this.config_.caseSensitive === false ? header.toLowerCase() : header, url: headerElement.attr('href') }); } diff --git a/test/main.js b/test/main.js index b6221b0..65b120a 100644 --- a/test/main.js +++ b/test/main.js @@ -187,6 +187,10 @@ describe('main - ', () => { shouldLoadPatternsFromPatternConfigFile ); + it('should load patterns with disabled case sensitive', + shouldLoadPatternsWithDisabledCaseSensitive + ); + it('should not return patters that match one of the exclude regexps', shouldNotReturnPattersThatMatchOneOfTheExcludeRegexps ); @@ -2058,6 +2062,64 @@ describe('main - ', () => { .then(done, done); } + function shouldLoadPatternsWithDisabledCaseSensitive(done) { + var randomInfo = 'data1-' + new Date().getTime(); + var randomInfo2 = 'data2-' + new Date().getTime(); + setUpFsMock({ + 'config.json': { + "screenSizes": {}, + "caseSensitive": false, + "patternConfigFile": "patternConfigFile.json" + }, + 'patternConfigFile.json': { + "patterns": { + "pattern-1": { + data: randomInfo + }, + "pattern-2": { + data: randomInfo2 + } + } + }, + 'dummyhtml/patterns.html': __dirname + '/dummyhtml/patterns.html' + }); + setUpPatternlabResponse( + 'http://localhost:3000', + 'dummyhtml/patterns.html' + ); + var instanceToTest = new patternlabToNode('config.json'); + instanceToTest.getPatternsConfiguration() + .then((patternConfig) => { + asserts.assertObjectEquals( + 'wrong pattern config', + { + "_patternOrder": [ + "pattern-1", + "pattern-2" + ], + "patterns": { + "pattern-1": { + id: "pattern-1", + name: "pattern name 1", + url: "link-to-pattern1.html", + data: randomInfo, + screenSizes: [] + }, + "pattern-2": { + id: "pattern-2", + name: "pattern name 2", + url: "link-to-pattern2.html", + data: randomInfo2, + screenSizes: [] + } + } + }, + patternConfig + ); + }) + .then(done, done); + } + function shouldNotReturnPattersThatMatchOneOfTheExcludeRegexps(done) { setUpFsMock({ From 687ee15e5315d382203c961d40b13f8c0eab6138 Mon Sep 17 00:00:00 2001 From: LarsHassler Date: Fri, 27 Oct 2017 17:48:17 +0200 Subject: [PATCH 3/3] chore(example): update example config file with new caseSensitive option --- example.config.json | 1 + 1 file changed, 1 insertion(+) diff --git a/example.config.json b/example.config.json index 266635c..1914a41 100644 --- a/example.config.json +++ b/example.config.json @@ -35,5 +35,6 @@ "^idea", "wip" ], + "caseSensitive": true, "patterns": null }