Skip to content

Commit

Permalink
Merge pull request #59 from LarsHassler/feat/case-insensitive
Browse files Browse the repository at this point in the history
Feature case-sensitive option
  • Loading branch information
LarsHassler committed Oct 27, 2017
2 parents 075cdf8 + 687ee15 commit 677c6a4
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 1 deletion.
11 changes: 11 additions & 0 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions example.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@
"^idea",
"wip"
],
"caseSensitive": true,
"patterns": null
}
3 changes: 2 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ var PatternlabToNode = function(options) {
defaultSizes: null,
loadOnSinglePage: false,
groupTestsByType: false,
caseSensitive: true,
patterns: null
}, settings);

Expand Down Expand Up @@ -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')
});
}
Expand Down
62 changes: 62 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 677c6a4

Please sign in to comment.