forked from pattern-lab/patternlab-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: pattern wrap classes reading from markdown and/or json
Refs: pattern-lab#1432
- Loading branch information
Showing
5 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
packages/core/test/files/_patterns/test/pattern-wrap-class-json.json
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 @@ | ||
{ | ||
"theme-class": "json-theme-class" | ||
} |
1 change: 1 addition & 0 deletions
1
packages/core/test/files/_patterns/test/pattern-wrap-class-json.mustache
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 @@ | ||
bar |
3 changes: 3 additions & 0 deletions
3
packages/core/test/files/_patterns/test/pattern-wrap-class-markdown.md
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 @@ | ||
--- | ||
theme-class: markdown-theme-class | ||
--- |
1 change: 1 addition & 0 deletions
1
packages/core/test/files/_patterns/test/pattern-wrap-class-markdown.mustache
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 @@ | ||
bar |
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,53 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const tap = require('tap'); | ||
|
||
const loadPattern = require('../src/lib/loadPattern'); | ||
const patternWrapClassesChangePatternTemplate = require('../src/lib/patternWrapClasses'); | ||
const util = require('./util/test_utils.js'); | ||
const patternEngines = require('../src/lib/pattern_engines'); | ||
const config = require('./util/patternlab-config.json'); | ||
|
||
patternEngines.loadAllEngines(config); | ||
|
||
const patterns_dir = `${__dirname}/files/_patterns`; | ||
|
||
tap.test('reading pattern wrap class from markdown', function (test) { | ||
const patternlab = util.fakePatternLab(patterns_dir); | ||
patternlab.config = { | ||
...patternlab.config, | ||
patternWrapClassesEnable: true, | ||
patternWrapClassesKey: ['theme-class'], | ||
}; | ||
|
||
const patternPathMarkdown = path.join( | ||
'test', | ||
'pattern-wrap-class-markdown.mustache' | ||
); | ||
const patternMarkdown = loadPattern(patternPathMarkdown, patternlab); | ||
patternWrapClassesChangePatternTemplate(patternlab, patternMarkdown); | ||
const patternPartialMarkdown = | ||
'<div class="pl-pattern-wrapper-element markdown-theme-class"></div>'; | ||
|
||
test.equal(patternMarkdown.patternPartialCode, patternPartialMarkdown); | ||
test.end(); | ||
}); | ||
|
||
tap.test('reading pattern wrap class from json', function (test) { | ||
const patternlab = util.fakePatternLab(patterns_dir); | ||
patternlab.config = { | ||
...patternlab.config, | ||
patternWrapClassesEnable: true, | ||
patternWrapClassesKey: ['theme-class'], | ||
}; | ||
|
||
const patternPathJson = path.join('test', 'pattern-wrap-class-json.mustache'); | ||
const patternJson = loadPattern(patternPathJson, patternlab); | ||
patternWrapClassesChangePatternTemplate(patternlab, patternJson); | ||
const patternPartialJson = | ||
'<div class="pl-pattern-wrapper-element json-theme-class"></div>'; | ||
|
||
test.equal(patternJson.patternPartialCode, patternPartialJson); | ||
test.end(); | ||
}); |