@penskemediacorp/larva 1.25.0 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/fixtures/larva.config.js +9 -16
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.featured.aia.js +2 -2
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.featured.js +2 -2
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.js +1 -1
- package/__tests__/fixtures/src/patterns/components/c-nav-link/c-nav-link.prototype.js +2 -2
- package/__tests__/fixtures/src/patterns/components/c-tagline/c-tagline.prototype.js +2 -2
- package/__tests__/fixtures/src/patterns/modules/_also-ignored/_also-ignored.prototype.js +2 -2
- package/__tests__/fixtures/src/patterns/modules/test-module/test-module.featured.js +2 -2
- package/__tests__/fixtures/src/patterns/modules/test-module/test-module.prototype.js +2 -2
- package/__tests__/fixtures/src/patterns/one-offs/newswire/newswire.prototype.js +2 -2
- package/__tests__/lib/generateStatic.test.js +120 -86
- package/__tests__/lib/utils/clonePatternData.test.js +17 -10
- package/__tests__/lib/utils/getAllPatternsObj.test.js +14 -29
- package/__tests__/lib/utils/getAppConfiguration.test.js +5 -5
- package/__tests__/lib/utils/getModuleNamesFromDirectory.test.js +29 -10
- package/__tests__/lib/utils/getPatternData.test.js +36 -23
- package/__tests__/lib/utils/getPatternPathsToLoad.test.js +5 -5
- package/__tests__/lib/utils/getPatternRoutes.test.js +4 -6
- package/__tests__/lib/utils/getPatternType.test.js +4 -4
- package/__tests__/lib/utils/getPatternVariants.test.js +7 -12
- package/__tests__/lib/utils/getPatternsIndexPath.test.js +9 -4
- package/__tests__/lib/utils/getSubDirectoryNames.test.js +16 -6
- package/__tests__/lib/utils/isCoreTheme.test.js +5 -3
- package/__tests__/lib/utils/writeJsonToFile.test.js +8 -10
- package/__tests__/lib/writeJson.test.js +39 -21
- package/bin/larva.js +6 -6
- package/build/css/larva-important.css +1 -1
- package/build/css/larva.css +1 -1
- package/build/css/larva.inline-important.css +1 -1
- package/build/css/larva.inline.css +1 -1
- package/build/js/standalone/video-showcase.js +7 -7
- package/build/svg/defs/sprite.defs.html +1 -1
- package/build/tokens/spy-2022.custom-properties.css +1 -0
- package/build/tokens/spy-2022.json +521 -0
- package/build/tokens/spy-2022.map.scss +536 -0
- package/build/tokens/spy-2022.raw.json +4039 -0
- package/index.js +1 -1
- package/lib/generateStatic.js +67 -63
- package/lib/server.js +139 -117
- package/lib/start.js +1 -1
- package/lib/utils/clonePatternData.js +1 -1
- package/lib/utils/copySyncHelper.js +5 -6
- package/lib/utils/getAllPatternsObj.js +14 -9
- package/lib/utils/getAppConfiguration.js +17 -15
- package/lib/utils/getArgsFromCli.js +2 -2
- package/lib/utils/getModuleNamesFromDirectory.js +13 -6
- package/lib/utils/getPatternData.js +19 -11
- package/lib/utils/getPatternPathsToLoad.js +5 -5
- package/lib/utils/getPatternRoutes.js +29 -27
- package/lib/utils/getPatternType.js +3 -3
- package/lib/utils/getPatternVariants.js +5 -6
- package/lib/utils/getPatternsIndexPath.js +3 -3
- package/lib/utils/getSubDirectoryNames.js +5 -5
- package/lib/utils/isCoreTheme.js +1 -2
- package/lib/utils/renderSass.js +17 -14
- package/lib/utils/spawnScript.js +4 -9
- package/lib/utils/writeJsonToFile.js +2 -2
- package/lib/writeJson.js +34 -15
- package/package.json +15 -12
- package/scripts/build-html.js +21 -14
- package/scripts/build-icons.js +38 -26
- package/scripts/build-scss.js +1 -1
- package/scripts/config/.eslintrc.json +2 -1
- package/scripts/config/gulpfile.js +0 -1
- package/scripts/config/stylelint.config.js +1 -1
- package/scripts/config/webpack.config.js +22 -20
- package/scripts/dev-js.js +1 -1
- package/scripts/dev-scss.js +2 -7
- package/scripts/help.js +9 -7
- package/scripts/init.js +4 -2
- package/scripts/larva/larva.config.js +1 -1
- package/scripts/link-all.js +2 -2
- package/scripts/lint-js.js +1 -4
- package/scripts/lint-scss.js +5 -7
- package/scripts/lint.js +4 -4
- package/scripts/prod-js.js +1 -4
- package/scripts/prod-scss.js +5 -2
- package/scripts/prod.js +16 -22
- package/scripts/server.js +1 -3
- package/scripts/start.js +3 -3
- package/scripts/upgrade.js +10 -14
- package/scripts/write-json.js +4 -2
|
@@ -1,43 +1,36 @@
|
|
|
1
1
|
const path = require( 'path' );
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
|
-
|
|
5
4
|
webpack: {
|
|
6
5
|
entry: {
|
|
7
6
|
common: './common.entry.js',
|
|
8
7
|
critical: './critical.entry.js',
|
|
9
8
|
special: './special.entry.js',
|
|
10
|
-
great: './great.entry.js'
|
|
11
|
-
}
|
|
9
|
+
great: './great.entry.js',
|
|
10
|
+
},
|
|
12
11
|
},
|
|
13
12
|
|
|
14
13
|
backstop: {
|
|
15
14
|
testBaseUrl: 'https://pmc:for-the-win@deadline-2019.pmcqa.com',
|
|
16
|
-
testPaths: [
|
|
17
|
-
'/',
|
|
18
|
-
'/blog/'
|
|
19
|
-
],
|
|
15
|
+
testPaths: [ '/', '/blog/' ],
|
|
20
16
|
testScenario: {
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
delay: 5000,
|
|
18
|
+
misMatchThreshold: 0.5,
|
|
23
19
|
},
|
|
24
|
-
larvaModules: [ 'footer', 'mega-menu-content', 'social-share' ]
|
|
20
|
+
larvaModules: [ 'footer', 'mega-menu-content', 'social-share' ],
|
|
25
21
|
},
|
|
26
22
|
|
|
27
23
|
patterns: {
|
|
28
24
|
projectPatternsDir: path.join( __dirname, './src/patterns' ),
|
|
29
25
|
larvaPatternsDir: path.resolve( __dirname, '../../../larva-patterns' ),
|
|
30
|
-
ignoredModules: [
|
|
31
|
-
'ignore-me'
|
|
32
|
-
]
|
|
26
|
+
ignoredModules: [ 'ignore-me' ],
|
|
33
27
|
},
|
|
34
28
|
|
|
35
29
|
assets: {
|
|
36
|
-
path: __dirname
|
|
30
|
+
path: __dirname,
|
|
37
31
|
},
|
|
38
32
|
|
|
39
33
|
parser: {
|
|
40
34
|
isCore: false,
|
|
41
35
|
},
|
|
42
|
-
|
|
43
|
-
};
|
|
36
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
modifier_class: 'featured aia'
|
|
3
|
-
};
|
|
2
|
+
modifier_class: 'featured aia',
|
|
3
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
modifier_class: 'featured'
|
|
3
|
-
};
|
|
2
|
+
modifier_class: 'featured',
|
|
3
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
// this could be JSX or a React component.
|
|
1
|
+
// this could be JSX or a React component.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
modifier_class: ''
|
|
3
|
-
};
|
|
2
|
+
modifier_class: '',
|
|
3
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
c_tagline_text: 'overrode the larva pattern'
|
|
3
|
-
}
|
|
2
|
+
c_tagline_text: 'overrode the larva pattern',
|
|
3
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
also_ignored_classes: 'lrv-u-color-black'
|
|
3
|
-
};
|
|
2
|
+
also_ignored_classes: 'lrv-u-color-black',
|
|
3
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
test_module_classes: 'lrv-a-glue'
|
|
3
|
-
}
|
|
2
|
+
test_module_classes: 'lrv-a-glue',
|
|
3
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
test_module_classes: 'lrv-u-flex'
|
|
3
|
-
}
|
|
2
|
+
test_module_classes: 'lrv-u-flex',
|
|
3
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
name:
|
|
3
|
-
};
|
|
2
|
+
name: 'newswire',
|
|
3
|
+
};
|
|
@@ -13,113 +13,149 @@ const buildPath = path.join( fixture, './build/html/project' );
|
|
|
13
13
|
beforeAll( ( done ) => {
|
|
14
14
|
app.listen( port, () => {
|
|
15
15
|
done();
|
|
16
|
-
});
|
|
17
|
-
});
|
|
16
|
+
} );
|
|
17
|
+
} );
|
|
18
18
|
|
|
19
19
|
describe( 'generateStatic', () => {
|
|
20
|
-
|
|
21
20
|
beforeEach( ( done ) => {
|
|
22
|
-
|
|
23
21
|
exec( 'mkdir -p ' + buildPath, ( err ) => {
|
|
24
22
|
if ( err ) {
|
|
25
23
|
console.error( err );
|
|
26
24
|
}
|
|
27
25
|
done();
|
|
28
26
|
} );
|
|
29
|
-
|
|
30
27
|
} );
|
|
31
28
|
|
|
32
29
|
it( 'creates an index.html file for a prototype pattern', ( done ) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
30
|
+
const routesArr = [ 'components/c-link' ];
|
|
31
|
+
|
|
32
|
+
generateStatic(
|
|
33
|
+
routesArr,
|
|
34
|
+
buildPath,
|
|
35
|
+
() => {
|
|
36
|
+
expect(
|
|
37
|
+
fs.existsSync(
|
|
38
|
+
path.join( buildPath, 'components/c-link/index.html' )
|
|
39
|
+
)
|
|
40
|
+
).toBe( true );
|
|
41
|
+
done();
|
|
42
|
+
},
|
|
43
|
+
urlBase
|
|
44
|
+
);
|
|
45
45
|
} );
|
|
46
46
|
|
|
47
47
|
it( 'creates an html file for a pattern variant', ( done ) => {
|
|
48
|
-
const routesArr = [
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
const routesArr = [ 'components/c-button/brand-basic' ];
|
|
49
|
+
|
|
50
|
+
generateStatic(
|
|
51
|
+
routesArr,
|
|
52
|
+
buildPath,
|
|
53
|
+
() => {
|
|
54
|
+
expect(
|
|
55
|
+
fs.existsSync(
|
|
56
|
+
path.join(
|
|
57
|
+
buildPath,
|
|
58
|
+
'components/c-button/brand-basic/index.html'
|
|
59
|
+
)
|
|
60
|
+
)
|
|
61
|
+
).toBe( true );
|
|
62
|
+
done();
|
|
63
|
+
},
|
|
64
|
+
urlBase
|
|
65
|
+
);
|
|
59
66
|
} );
|
|
60
67
|
|
|
61
68
|
it( 'contains content for the pattern', ( done ) => {
|
|
62
|
-
const routesArr = [
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
const routesArr = [ 'modules/footer' ];
|
|
70
|
+
|
|
71
|
+
generateStatic(
|
|
72
|
+
routesArr,
|
|
73
|
+
buildPath,
|
|
74
|
+
() => {
|
|
75
|
+
expect(
|
|
76
|
+
// Hacky way to test that the response actually contains
|
|
77
|
+
// the content, not an error.
|
|
78
|
+
fs
|
|
79
|
+
.readFileSync(
|
|
80
|
+
path.join(
|
|
81
|
+
buildPath,
|
|
82
|
+
routesArr[ 0 ] + '/index.html'
|
|
83
|
+
),
|
|
84
|
+
{ encoding: 'utf8' }
|
|
85
|
+
)
|
|
86
|
+
.indexOf( 'footer_classes' )
|
|
87
|
+
).not.toBe( -1 );
|
|
88
|
+
done();
|
|
89
|
+
},
|
|
90
|
+
urlBase
|
|
91
|
+
);
|
|
77
92
|
} );
|
|
78
93
|
|
|
79
94
|
it( 'copies static assets', ( done ) => {
|
|
80
|
-
const routesArr = [
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
95
|
+
const routesArr = [ 'components/c-button/brand-basic' ];
|
|
96
|
+
|
|
97
|
+
generateStatic(
|
|
98
|
+
routesArr,
|
|
99
|
+
buildPath,
|
|
100
|
+
() => {
|
|
101
|
+
// This is kinda sloppy and may be annoying to maintain, and there is
|
|
102
|
+
// surely a more elegant way to test this functionality than checking
|
|
103
|
+
// if the file exists...
|
|
104
|
+
|
|
105
|
+
// JS
|
|
106
|
+
expect(
|
|
107
|
+
fs.existsSync(
|
|
108
|
+
path.join( buildPath, '../assets/build/js/larva-ui.js' )
|
|
109
|
+
)
|
|
110
|
+
).toBe( true );
|
|
111
|
+
|
|
112
|
+
// CSS
|
|
113
|
+
expect(
|
|
114
|
+
fs.existsSync(
|
|
115
|
+
path.join(
|
|
116
|
+
buildPath,
|
|
117
|
+
'../assets/build/css/common.inline.css'
|
|
118
|
+
)
|
|
119
|
+
)
|
|
120
|
+
).toBe( true );
|
|
121
|
+
|
|
122
|
+
// Images
|
|
123
|
+
expect(
|
|
124
|
+
fs.existsSync(
|
|
125
|
+
path.join(
|
|
126
|
+
buildPath,
|
|
127
|
+
'../assets/build/images/test.png'
|
|
128
|
+
)
|
|
129
|
+
)
|
|
130
|
+
).toBe( true );
|
|
131
|
+
|
|
132
|
+
// SVG
|
|
133
|
+
expect(
|
|
134
|
+
fs.existsSync(
|
|
135
|
+
path.join(
|
|
136
|
+
buildPath,
|
|
137
|
+
'../assets/build/svg/defs/sprite.svg'
|
|
138
|
+
)
|
|
139
|
+
)
|
|
140
|
+
).toBe( true );
|
|
141
|
+
|
|
142
|
+
// Public dir
|
|
143
|
+
expect(
|
|
144
|
+
fs.existsSync(
|
|
145
|
+
path.join(
|
|
146
|
+
buildPath,
|
|
147
|
+
'../assets/public/some-library.js'
|
|
148
|
+
)
|
|
149
|
+
)
|
|
150
|
+
).toBe( true );
|
|
151
|
+
|
|
152
|
+
done();
|
|
153
|
+
},
|
|
154
|
+
urlBase
|
|
155
|
+
);
|
|
119
156
|
} );
|
|
120
157
|
|
|
121
158
|
afterEach( ( done ) => {
|
|
122
|
-
|
|
123
159
|
const htmlDir = path.join( buildPath, '../' );
|
|
124
160
|
|
|
125
161
|
exec( 'rm -r ' + htmlDir, ( err ) => {
|
|
@@ -128,13 +164,11 @@ describe( 'generateStatic', () => {
|
|
|
128
164
|
}
|
|
129
165
|
done();
|
|
130
166
|
} );
|
|
131
|
-
|
|
132
167
|
} );
|
|
133
|
-
|
|
134
168
|
} );
|
|
135
169
|
|
|
136
170
|
afterAll( async ( done ) => {
|
|
137
171
|
const server = app.listen();
|
|
138
172
|
server.close();
|
|
139
173
|
done();
|
|
140
|
-
});
|
|
174
|
+
} );
|
|
@@ -4,20 +4,27 @@ const getConfig = require( '../../../lib/utils/getAppConfiguration' );
|
|
|
4
4
|
const { projectPatternsDir, larvaPatternsDir } = getConfig( 'patterns' );
|
|
5
5
|
|
|
6
6
|
describe( 'clonePatternData', () => {
|
|
7
|
-
|
|
8
7
|
it( 'gets object from project patterns dir first', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const expected = require( path.join(
|
|
9
|
+
projectPatternsDir,
|
|
10
|
+
'/components/c-tagline/c-tagline.prototype'
|
|
11
|
+
) );
|
|
12
|
+
const c_tagline = clonePatternData(
|
|
13
|
+
'components/c-tagline/c-tagline.prototype'
|
|
14
|
+
);
|
|
12
15
|
|
|
13
16
|
expect( c_tagline ).toStrictEqual( expected );
|
|
14
|
-
});
|
|
17
|
+
} );
|
|
15
18
|
|
|
16
19
|
it( 'falls back to object from larva patterns dir', () => {
|
|
17
|
-
const expected = require( path.join(
|
|
18
|
-
|
|
20
|
+
const expected = require( path.join(
|
|
21
|
+
larvaPatternsDir,
|
|
22
|
+
'/components/c-button/c-button.prototype'
|
|
23
|
+
) );
|
|
24
|
+
const c_button = clonePatternData(
|
|
25
|
+
'components/c-button/c-button.prototype'
|
|
26
|
+
);
|
|
19
27
|
|
|
20
28
|
expect( c_button ).toStrictEqual( expected );
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
});
|
|
29
|
+
} );
|
|
30
|
+
} );
|
|
@@ -3,43 +3,28 @@ const getAppConfiguration = require( '../../../lib/utils/getAppConfiguration' );
|
|
|
3
3
|
const getAllPatternsObj = require( '../../../lib/utils/getAllPatternsObj' );
|
|
4
4
|
|
|
5
5
|
const expectedPatterns = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
'c-nav-link': [
|
|
9
|
-
|
|
10
|
-
'featured',
|
|
11
|
-
'prototype'
|
|
12
|
-
],
|
|
13
|
-
'c-tagline': [
|
|
14
|
-
'prototype'
|
|
15
|
-
]
|
|
6
|
+
__tests__: {},
|
|
7
|
+
components: {
|
|
8
|
+
'c-nav-link': [ 'featured.aia', 'featured', 'prototype' ],
|
|
9
|
+
'c-tagline': [ 'prototype' ],
|
|
16
10
|
},
|
|
17
|
-
|
|
18
|
-
'test-module': [
|
|
19
|
-
'featured',
|
|
20
|
-
'prototype'
|
|
21
|
-
]
|
|
11
|
+
modules: {
|
|
12
|
+
'test-module': [ 'featured', 'prototype' ],
|
|
22
13
|
},
|
|
23
|
-
|
|
14
|
+
objects: {
|
|
24
15
|
'o-crap': [],
|
|
25
|
-
'o-nav': []
|
|
16
|
+
'o-nav': [],
|
|
26
17
|
},
|
|
27
18
|
'one-offs': {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
}
|
|
19
|
+
newswire: [ 'prototype' ],
|
|
20
|
+
},
|
|
21
|
+
};
|
|
33
22
|
const config = getAppConfiguration( 'patterns' );
|
|
34
23
|
|
|
35
24
|
describe( 'getAllPatternsObj', () => {
|
|
36
|
-
|
|
37
25
|
it( 'returns an object containing all patterns and variants', () => {
|
|
38
|
-
|
|
39
|
-
expect(
|
|
40
|
-
getAllPatternsObj( config.projectPatternsDir )
|
|
41
|
-
).toEqual(
|
|
26
|
+
expect( getAllPatternsObj( config.projectPatternsDir ) ).toEqual(
|
|
42
27
|
expectedPatterns
|
|
43
28
|
);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
29
|
+
} );
|
|
30
|
+
} );
|
|
@@ -5,9 +5,9 @@ const getAppConfiguration = require( '../../../lib/utils/getAppConfiguration' );
|
|
|
5
5
|
const expectedLarvaConfig = require( fixture + '/larva.config.js' );
|
|
6
6
|
|
|
7
7
|
describe( 'getAppConfiguration', () => {
|
|
8
|
-
|
|
9
8
|
it( 'Get Larva Configuration', () => {
|
|
10
|
-
expect(getAppConfiguration( 'backstop' )).toStrictEqual(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
9
|
+
expect( getAppConfiguration( 'backstop' ) ).toStrictEqual(
|
|
10
|
+
expectedLarvaConfig.backstop
|
|
11
|
+
);
|
|
12
|
+
} );
|
|
13
|
+
} );
|
|
@@ -5,19 +5,38 @@ const config = getAppConfiguration( 'patterns' );
|
|
|
5
5
|
|
|
6
6
|
describe( 'getModuleNamesFromDirectory', () => {
|
|
7
7
|
it( 'gets an array of modules', () => {
|
|
8
|
-
expect(
|
|
9
|
-
|
|
8
|
+
expect(
|
|
9
|
+
getModuleNamesFromDirectory(
|
|
10
|
+
config.projectPatternsDir,
|
|
11
|
+
config.ignoredModules
|
|
12
|
+
)
|
|
13
|
+
).toEqual( expect.arrayContaining( [ 'test-module' ] ) );
|
|
14
|
+
} );
|
|
10
15
|
|
|
11
16
|
it( 'ignored modules with underscores', () => {
|
|
12
|
-
expect(
|
|
13
|
-
|
|
17
|
+
expect(
|
|
18
|
+
getModuleNamesFromDirectory(
|
|
19
|
+
config.projectPatternsDir,
|
|
20
|
+
config.ignoredModules
|
|
21
|
+
)
|
|
22
|
+
).toEqual( expect.not.arrayContaining( [ '_also-ignored' ] ) );
|
|
23
|
+
} );
|
|
14
24
|
|
|
15
25
|
it( 'ignores modules listed in larva.config.ignoredModules', () => {
|
|
16
|
-
expect(
|
|
17
|
-
|
|
26
|
+
expect(
|
|
27
|
+
getModuleNamesFromDirectory(
|
|
28
|
+
config.projectPatternsDir,
|
|
29
|
+
config.ignoredModules
|
|
30
|
+
)
|
|
31
|
+
).toEqual( expect.not.arrayContaining( [ 'ignore-me' ] ) );
|
|
32
|
+
} );
|
|
18
33
|
|
|
19
34
|
it( 'gets module names from larva', () => {
|
|
20
|
-
expect(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
35
|
+
expect(
|
|
36
|
+
getModuleNamesFromDirectory(
|
|
37
|
+
config.larvaPatternsDir,
|
|
38
|
+
config.ignoredModules
|
|
39
|
+
)
|
|
40
|
+
).toEqual( expect.arrayContaining( [ 'pmc-footer' ] ) );
|
|
41
|
+
} );
|
|
42
|
+
} );
|
|
@@ -4,52 +4,65 @@ const fs = require( 'fs' );
|
|
|
4
4
|
const fixture = path.join( __dirname, '../../fixtures' );
|
|
5
5
|
|
|
6
6
|
const getPatternData = require( '../../../lib/utils/getPatternData' );
|
|
7
|
-
const appConfiguration = require( '../../../lib/utils/getAppConfiguration' )(
|
|
7
|
+
const appConfiguration = require( '../../../lib/utils/getAppConfiguration' )(
|
|
8
|
+
'patterns'
|
|
9
|
+
);
|
|
8
10
|
|
|
9
|
-
const expectedSchema = require( fixture +
|
|
10
|
-
|
|
11
|
-
const
|
|
11
|
+
const expectedSchema = require( fixture +
|
|
12
|
+
'/src/patterns/components/c-nav-link/c-nav-link.prototype.js' );
|
|
13
|
+
const expectedVariantSchema = require( fixture +
|
|
14
|
+
'/src/patterns/components/c-nav-link/c-nav-link.featured.js' );
|
|
15
|
+
const expectedSchemaFromJson = require( fixture +
|
|
16
|
+
'/src/patterns/objects/o-crap/o-crap.json' );
|
|
12
17
|
const expectedPath = fixture + '/src/patterns/objects/o-nav/o-nav.json';
|
|
13
|
-
const expectedOneOffSchema = require( fixture +
|
|
18
|
+
const expectedOneOffSchema = require( fixture +
|
|
19
|
+
'/src/patterns/one-offs/newswire/newswire.prototype.js' );
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
const compStub = {
|
|
16
22
|
name: 'c-nav-link',
|
|
17
23
|
type: 'components',
|
|
18
|
-
variant: 'prototype'
|
|
24
|
+
variant: 'prototype',
|
|
19
25
|
};
|
|
20
26
|
|
|
21
27
|
const objStub = {
|
|
22
28
|
name: 'o-crap',
|
|
23
29
|
type: 'objects',
|
|
24
|
-
variant: 'prototype'
|
|
30
|
+
variant: 'prototype',
|
|
25
31
|
};
|
|
26
32
|
|
|
27
33
|
const oneOffStub = {
|
|
28
34
|
name: 'newswire',
|
|
29
35
|
type: 'one-offs',
|
|
30
|
-
variant: 'prototype'
|
|
36
|
+
variant: 'prototype',
|
|
31
37
|
};
|
|
32
38
|
|
|
33
39
|
describe( 'getPatternData', () => {
|
|
34
|
-
|
|
35
40
|
it( 'first returns the pattern object if the schema is found', () => {
|
|
36
|
-
assert.equal(
|
|
37
|
-
|
|
41
|
+
assert.equal(
|
|
42
|
+
getPatternData( fixture + '/src/patterns', compStub ),
|
|
43
|
+
expectedSchema
|
|
44
|
+
);
|
|
45
|
+
} );
|
|
38
46
|
|
|
39
47
|
it( 'returns the pattern object for one-offs', () => {
|
|
40
|
-
assert.equal(
|
|
41
|
-
|
|
48
|
+
assert.equal(
|
|
49
|
+
getPatternData( fixture + '/src/patterns', oneOffStub ),
|
|
50
|
+
expectedOneOffSchema
|
|
51
|
+
);
|
|
52
|
+
} );
|
|
42
53
|
|
|
43
54
|
it( 'returns the pattern json object if no prototype is found', () => {
|
|
44
|
-
assert.equal(
|
|
45
|
-
|
|
55
|
+
assert.equal(
|
|
56
|
+
getPatternData( fixture + '/src/patterns', objStub ),
|
|
57
|
+
expectedSchemaFromJson
|
|
58
|
+
);
|
|
59
|
+
} );
|
|
46
60
|
|
|
47
61
|
it( 'gets a variant specified in params', () => {
|
|
48
62
|
compStub.variant = 'featured';
|
|
49
|
-
assert.equal(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
63
|
+
assert.equal(
|
|
64
|
+
getPatternData( fixture + '/src/patterns', compStub ),
|
|
65
|
+
expectedVariantSchema
|
|
66
|
+
);
|
|
67
|
+
} );
|
|
68
|
+
} );
|
|
@@ -2,12 +2,12 @@ const assert = require( 'assert' );
|
|
|
2
2
|
const path = require( 'path' );
|
|
3
3
|
const fixture = path.join( __dirname, '../../fixtures' );
|
|
4
4
|
const getPatternPathsToLoad = require( '../../../lib/utils/getPatternPathsToLoad' );
|
|
5
|
-
const appConfiguration = require( '../../../lib/utils/getAppConfiguration' )(
|
|
5
|
+
const appConfiguration = require( '../../../lib/utils/getAppConfiguration' )(
|
|
6
|
+
'patterns'
|
|
7
|
+
);
|
|
6
8
|
|
|
7
9
|
describe( 'getPatternPathsToLoad', () => {
|
|
8
|
-
|
|
9
10
|
it( 'returns an array of paths loads larvaPath if it is the core theme', () => {
|
|
10
11
|
assert.equal( getPatternPathsToLoad( appConfiguration ).length, 2 );
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
});
|
|
12
|
+
} );
|
|
13
|
+
} );
|
|
@@ -5,10 +5,10 @@ const getAllPatternsObj = require( '../../../lib/utils/getAllPatternsObj' );
|
|
|
5
5
|
const getPatternRoutes = require( '../../../lib/utils/getPatternRoutes' );
|
|
6
6
|
|
|
7
7
|
describe( 'getPatternRoutes', () => {
|
|
8
|
-
|
|
9
8
|
it( 'outputs an array of routes from a pattern object', () => {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const patterns = getAllPatternsObj(
|
|
10
|
+
path.join( fixture, 'src/patterns' )
|
|
11
|
+
);
|
|
12
12
|
|
|
13
13
|
const expected = [
|
|
14
14
|
'components/c-nav-link/featured.aia',
|
|
@@ -19,11 +19,9 @@ describe( 'getPatternRoutes', () => {
|
|
|
19
19
|
'modules/test-module',
|
|
20
20
|
'objects/o-crap',
|
|
21
21
|
'objects/o-nav',
|
|
22
|
-
'one-offs/newswire'
|
|
22
|
+
'one-offs/newswire',
|
|
23
23
|
];
|
|
24
24
|
|
|
25
25
|
expect( getPatternRoutes( patterns ) ).toStrictEqual( expected );
|
|
26
|
-
|
|
27
26
|
} );
|
|
28
|
-
|
|
29
27
|
} );
|