-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #655 from pattern-lab/dev
Pattern Lab Node Core 2.9.2
- Loading branch information
Showing
15 changed files
with
156 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
{ | ||
"test_list_item" : "izzn thizzle" | ||
"1": { | ||
"title": "Nullizzle shizznit velizzle, hizzle, suscipit own yo', gravida vizzle, arcu." | ||
}, | ||
"2": { | ||
"title": "Veggies sunt bona vobis, proinde vos postulo" | ||
}, | ||
"3": { | ||
"title": "Bacon ipsum dolor sit amet turducken strip steak beef ribs shank" | ||
} | ||
} | ||
|
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="{{styleModifier}}"> | ||
{{> test-link }} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"url" : "link.test-foo" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{> test-paramMiddle(styleModifier: "foo") }} |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,73 @@ | ||
'use strict'; | ||
|
||
var tap = require('tap'); | ||
const tap = require('tap'); | ||
const rewire = require("rewire"); | ||
const _ = require('lodash'); | ||
const fs = require('fs-extra'); | ||
var config = require('./util/patternlab-config.json'); | ||
|
||
var plEngineModule = rewire('../core/lib/patternlab'); | ||
|
||
//set up a global mocks - we don't want to be writing/rendering any files right now | ||
const uiBuilderMock = { | ||
buildFrontend: function (patternlab) { } | ||
}; | ||
|
||
const fsMock = { | ||
outputFileSync: function (path, content) { /* INTENTIONAL NOOP */}, | ||
readJSONSync: function(path, encoding) { | ||
return fs.readJSONSync(path, encoding); | ||
}, | ||
removeSync: function(path) { fs.removeSync(path); }, | ||
emptyDirSync: function(path) { fs.emptyDirSync(path); }, | ||
readFileSync: function(path, encoding) { return fs.readFileSync(path, encoding); }, | ||
} | ||
|
||
//set our mocks in place of usual require() | ||
plEngineModule.__set__({ | ||
'ui_builder': uiBuilderMock, | ||
'fs': fsMock | ||
}); | ||
|
||
tap.test('buildPatternData - should merge all JSON files in the data folder except listitems', function(test){ | ||
var fs = require('fs-extra'); | ||
var plMain = require('../core/lib/patternlab'); | ||
var data_dir = './test/files/_data/'; | ||
|
||
var dataResult = plMain.build_pattern_data(data_dir, fs); | ||
var dataResult = plEngineModule.build_pattern_data(data_dir, fs); | ||
test.equals(dataResult.data, "test"); | ||
test.equals(dataResult.foo, "bar"); | ||
test.equals(dataResult.test_list_item, undefined); | ||
test.end(); | ||
}); | ||
|
||
tap.test('buildPatterns - should replace data link even when pattern parameter present', function(test) { | ||
//arrange | ||
|
||
var patternExporterMock = { | ||
/* | ||
In this test, we actually take advantage of the pattern export functionality post-build to inspect what | ||
the contents of the patterns look like. This, coupled with a mocking of fs and the ui_builder, allow us to focus | ||
only on the order of events within build. | ||
*/ | ||
export_patterns: function (patternlab) { | ||
var pattern = _.find(patternlab.patterns, (pattern) => { | ||
return pattern.patternPartial === 'test-paramParent'; | ||
}); | ||
//assert | ||
test.equals(pattern.patternPartialCode.indexOf('00-test-00-foo.rendered.html') > -1, true, 'data link should be replaced properly'); | ||
} | ||
}; | ||
|
||
plEngineModule.__set__({ | ||
'pattern_exporter': patternExporterMock | ||
}); | ||
|
||
config.patternExportPatternPartials = ['test-paramParent']; | ||
var pl = new plEngineModule(config); | ||
|
||
//act | ||
pl.build(function() { | ||
test.end(); | ||
}, true); | ||
|
||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{ | ||
"paths" : { | ||
"source" : { | ||
"root": "./test/files/", | ||
"patterns" : "./test/files/_patterns/", | ||
"data" : "./test/files/_data/", | ||
"meta": "./test/files/_meta/", | ||
"styleguide" : "./test/files/styleguide/", | ||
"patternlabFiles" : "./test/files/", | ||
"js" : "./test/files/js", | ||
"images" : "./test/files/images", | ||
"fonts" : "./test/files/fonts", | ||
"css" : "./test/files/css/" | ||
}, | ||
"public" : { | ||
"root" : "./test/public/", | ||
"patterns" : "./test/public/patterns/", | ||
"data" : "./test/public/data/", | ||
"styleguide" : "./test/public/styleguide/", | ||
"js" : "./test/public/js", | ||
"images" : "./test/public/images", | ||
"fonts" : "./test/public/fonts", | ||
"css" : "./test/public/css" | ||
} | ||
}, | ||
"styleGuideExcludes": [ | ||
"templates", | ||
"pages" | ||
], | ||
"defaultPattern": "all", | ||
"ignored-extensions" : ["scss", "DS_Store", "less"], | ||
"ignored-directories" : ["scss"], | ||
"debug": false, | ||
"ishControlsHide": { | ||
"s": false, | ||
"m": false, | ||
"l": false, | ||
"full": false, | ||
"random": false, | ||
"disco": false, | ||
"hay": true, | ||
"mqs": false, | ||
"find": false, | ||
"views-all": false, | ||
"views-annotations": false, | ||
"views-code": false, | ||
"views-new": false, | ||
"tools-all": false, | ||
"tools-docs": false | ||
}, | ||
"ishMinimum": "240", | ||
"ishMaximum": "2600", | ||
"patternStateCascade": ["inprogress", "inreview", "complete"], | ||
"patternStates": { | ||
}, | ||
"patternExportPatternPartials": [], | ||
"patternExportDirectory": "./pattern_exports/", | ||
"cacheBust": true, | ||
"outputFileSuffixes": { | ||
"rendered": ".rendered", | ||
"rawTemplate": "", | ||
"markupOnly": ".markup-only" | ||
}, | ||
"cleanOutputHtml": true, | ||
"exportToGraphViz": false, | ||
"cleanPublic": true | ||
} |