Skip to content

Commit

Permalink
added deprecation warning to setState
Browse files Browse the repository at this point in the history
removed it from all unit tests
  • Loading branch information
bmuenzenmeyer committed Jul 4, 2016
1 parent d554e8d commit 9a33208
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 111 deletions.
17 changes: 11 additions & 6 deletions core/lib/pattern_assembler.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,17 @@ var pattern_assembler = function () {

/*
* Deprecated in favor of .md 'status' frontmatter inside a pattern. Still used for unit tests at this time.
* Will be removed in future versions
*/
function setState(pattern, patternlab) {
function setState(pattern, patternlab, displayDeprecatedWarning) {
if (patternlab.config.patternStates && patternlab.config.patternStates[pattern.patternPartial]) {

if (displayDeprecatedWarning) {
plutils.logRed("Deprecation Warning: Using patternlab-config.json patternStates object will be deprecated in favor of the state frontmatter key associated with individual pattern markdown files.");
console.log("This feature will still work in it's current form this release (but still be overridden by the new parsing method), and will be removed in the future.");
}

pattern.patternState = patternlab.config.patternStates[pattern.patternPartial];
} else {
pattern.patternState = "";
}
}

Expand Down Expand Up @@ -200,7 +205,7 @@ var pattern_assembler = function () {
}

//see if this file has a state
//setState(currentPattern, patternlab);
setState(currentPattern, patternlab, true);

//look for a json file for this template
try {
Expand Down Expand Up @@ -412,8 +417,8 @@ var pattern_assembler = function () {
find_list_items: function (pattern) {
return pattern.findListItems();
},
setPatternState: function (pattern, patternlab) {
setState(pattern, patternlab);
setPatternState: function (pattern, patternlab, displayDeprecatedWarning) {
setState(pattern, patternlab, displayDeprecatedWarning);
},
addPattern: function (pattern, patternlab) {
addPattern(pattern, patternlab);
Expand Down
31 changes: 7 additions & 24 deletions test/lineage_hunter_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,22 +159,18 @@ exports['lineage hunter '] = {
'cascade_pattern_states promotes a lower pattern state up to the consumer': function (test) {
//arrange
var pl = createBasePatternLabObject();
pl.config.patternStates = {
"test-foo": "complete",
"test-bar": "inreview"
};

var atomPattern = new of.Pattern('00-test/01-bar.mustache');
atomPattern.template = fs.readFileSync(pl.config.paths.source.patterns + '00-test/01-bar.mustache', 'utf8');
atomPattern.extendedTemplate = atomPattern.template;
atomPattern.patternState = "inreview";

pattern_assembler.setPatternState(atomPattern, pl);
pattern_assembler.addPattern(atomPattern, pl);

var consumerPattern = new of.Pattern('00-test/00-foo.mustache');
consumerPattern.template = fs.readFileSync(pl.config.paths.source.patterns + '00-test/00-foo.mustache', 'utf8');
consumerPattern.extendedTemplate = consumerPattern.template;
pattern_assembler.setPatternState(consumerPattern, pl);
consumerPattern.patternState = "complete";
pattern_assembler.addPattern(consumerPattern, pl);

lineage_hunter.find_lineage(consumerPattern, pl);
Expand All @@ -191,22 +187,18 @@ exports['lineage hunter '] = {
'cascade_pattern_states promotes a lower pattern state up to the consumers lineage': function (test) {
//arrange
var pl = createBasePatternLabObject();
pl.config.patternStates = {
"test-foo": "complete",
"test-bar": "inreview"
};

var atomPattern = new of.Pattern('00-test/01-bar.mustache');
atomPattern.template = fs.readFileSync(pl.config.paths.source.patterns + '00-test/01-bar.mustache', 'utf8');
atomPattern.extendedTemplate = atomPattern.template;
atomPattern.patternState = "inreview";

pattern_assembler.setPatternState(atomPattern, pl);
pattern_assembler.addPattern(atomPattern, pl);

var consumerPattern = new of.Pattern('00-test/00-foo.mustache');
consumerPattern.template = fs.readFileSync(pl.config.paths.source.patterns + '00-test/00-foo.mustache', 'utf8');
consumerPattern.extendedTemplate = consumerPattern.template;
pattern_assembler.setPatternState(consumerPattern, pl);
consumerPattern.patternState = "complete";
pattern_assembler.addPattern(consumerPattern, pl);

lineage_hunter.find_lineage(consumerPattern, pl);
Expand All @@ -223,22 +215,17 @@ exports['lineage hunter '] = {
'cascade_pattern_states sets the pattern state on any lineage patterns reverse lineage': function (test) {
//arrange
var pl = createBasePatternLabObject();
pl.config.patternStates = {
"test-foo": "complete",
"test-bar": "inreview"
};

var atomPattern = new of.Pattern('00-test/01-bar.mustache');
atomPattern.template = fs.readFileSync(pl.config.paths.source.patterns + '00-test/01-bar.mustache', 'utf8');
atomPattern.extendedTemplate = atomPattern.template;

pattern_assembler.setPatternState(atomPattern, pl);
atomPattern.patternState = "inreview";
pattern_assembler.addPattern(atomPattern, pl);

var consumerPattern = new of.Pattern('00-test/00-foo.mustache');
consumerPattern.template = fs.readFileSync(pl.config.paths.source.patterns + '00-test/00-foo.mustache', 'utf8');
consumerPattern.extendedTemplate = consumerPattern.template;
pattern_assembler.setPatternState(consumerPattern, pl);
consumerPattern.patternState = "complete";
pattern_assembler.addPattern(consumerPattern, pl);

lineage_hunter.find_lineage(consumerPattern, pl);
Expand All @@ -256,21 +243,17 @@ exports['lineage hunter '] = {
'cascade_pattern_states promotes lower pattern state when consumer does not have its own state': function (test) {
//arrange
var pl = createBasePatternLabObject();
pl.config.patternStates = {
"test-bar": "inreview"
};

var atomPattern = new of.Pattern('00-test/01-bar.mustache');
atomPattern.template = fs.readFileSync(path.resolve(pl.config.paths.source.patterns, '00-test/01-bar.mustache'), 'utf8');
atomPattern.extendedTemplate = atomPattern.template;
atomPattern.patternState = "inreview";

pattern_assembler.setPatternState(atomPattern, pl);
pattern_assembler.addPattern(atomPattern, pl);

var consumerPattern = new of.Pattern('00-test/00-foo.mustache');
consumerPattern.template = fs.readFileSync(path.resolve(pl.config.paths.source.patterns, '00-test/00-foo.mustache'), 'utf8');
consumerPattern.extendedTemplate = consumerPattern.template;
pattern_assembler.setPatternState(consumerPattern, pl);
pattern_assembler.addPattern(consumerPattern, pl);

lineage_hunter.find_lineage(consumerPattern, pl);
Expand Down
83 changes: 2 additions & 81 deletions test/pattern_assembler_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,86 +6,6 @@
var path = require('path');

exports['pattern_assembler'] = {

//'find_pattern_partials_with_parameters finds parameters' : function(test){
//test.expect(2);
//
// //setup current pattern from what we would have during execution
//var currentPattern = new Pattern(
// '01-molecules/00-testing/00-test-mol.mustache', // relative path now
// null // data
//);
// currentPattern.template = "<h1>{{> molecules-comment-header}}</h1><div>{{> molecules-single-comment(bar:'baz') }}</div>";
//
//var results = currentPattern.findPartialsWithPatternParameters();
// test.equals(results.length, 1);
// test.equals(results[0], "{{> molecules-single-comment(bar:'baz') }}");
//
// test.done();
//
//},
//'find_pattern_partials_with_parameters finds parameters when stylemodifiers present too' : function(test){
//test.expect(2);
//
// //setup current pattern from what we would have during execution
//var currentPattern = new Pattern(
// '01-molecules/00-testing/00-test-mol.mustache', // relative path now
// null // data
//);
// currentPattern.template = "<h1>{{> molecules-comment-header}}</h1><div>{{> molecules-single-comment:foo(bar:'baz') }}</div>";
//
//var results = currentPattern.findPartialsWithPatternParameters();
// test.equals(results.length, 1);
// test.equals(results[0], "{{> molecules-single-comment:foo(bar:'baz') }}");
//
// test.done();
//},
//'find_pattern_partials_with_parameters finds parameters with verbose partials' : function(test){
//test.expect(2);
//
// //setup current pattern from what we would have during execution
//var currentPattern = new Pattern(
// '01-molecules/00-testing/00-test-mol.mustache', // relative path now
// null // data
//);
// currentPattern.template = "<h1>{{> 01-molecules/06-components/molecules-comment-header}}</h1><div>{{> 01-molecules/06-components/molecules-single-comment(bar:'baz') }}</div>";
//
//var results = currentPattern.findPartialsWithPatternParameters();
// test.equals(results.length, 1);
// test.equals(results[0], "{{> 01-molecules/06-components/molecules-single-comment(bar:'baz') }}");
//
// test.done();
//},
//'find_pattern_partials_with_parameters finds no style modifiers when only partials present' : function(test){
//test.expect(1);
//
// //setup current pattern from what we would have during execution
//var currentPattern = new Pattern(
// '01-molecules/00-testing/00-test-mol.mustache', // relative path now
// null // data
//);
// currentPattern.template = "<h1>{{> molecules-comment-header}}</h1><div>{{> molecules-single-comment }}</div>";
//
//var results = currentPattern.findPartialsWithPatternParameters();
// test.equals(results, null);
//
// test.done();
//},
//'find_pattern_partials_with_parameters finds no style modifiers when only partials with style modifiers present' : function(test){
//test.expect(1);
//
// //setup current pattern from what we would have during execution
//var currentPattern = new Pattern(
// '01-molecules/00-testing/00-test-mol.mustache', // relative path now
// null // data
//);
// currentPattern.template = "<h1>{{> molecules-comment-header}}</h1><div>{{> molecules-single-comment:foo }}</div>";
//
//var results = currentPattern.findPartialsWithPatternParameters();
// test.equals(results, null);
//
// test.done();
//},
'process_pattern_recursive recursively includes partials' : function(test){
test.expect(3);

Expand Down Expand Up @@ -413,7 +333,8 @@
patternlab.config.patternStates["pages-homepage-emergency"] = "inprogress";

var pattern = {
key: "pages-homepage"
key: "pages-homepage",
patternState: ""
};

//act
Expand Down

0 comments on commit 9a33208

Please sign in to comment.