-
Notifications
You must be signed in to change notification settings - Fork 685
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into 1617-fetch-store-name-from-graphql-at-bui…
…ld-time
- Loading branch information
Showing
13 changed files
with
326 additions
and
15 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
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
70 changes: 70 additions & 0 deletions
70
packages/pwa-buildpack/lib/WebpackTools/__tests__/getModuleRules.spec.js
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,70 @@ | ||
const getModuleRules = require('../configureWebpack/getModuleRules'); | ||
|
||
describe('css', async () => { | ||
const helper = { | ||
mode: 'development', | ||
paths: { | ||
src: 'unit_test' | ||
}, | ||
hasFlag: () => [], | ||
babelRootMode: 'unit_test', | ||
transformRequests: { | ||
babel: {}, | ||
source: {} | ||
} | ||
}; | ||
const isStyleLoaderRule = rule => { | ||
return rule.loader === 'style-loader'; | ||
}; | ||
const injectTypeIs = value => { | ||
return rule => rule.options.injectType === value; | ||
}; | ||
const injectTypeIsStyleTag = injectTypeIs('styleTag'); | ||
const injectTypeIsSingletonStyleTag = injectTypeIs('singletonStyleTag'); | ||
|
||
test('style loader inject type is "styleTag" in development', async () => { | ||
// Arrange. | ||
|
||
// Act. | ||
const rules = await getModuleRules(helper); | ||
|
||
// Assert. | ||
// Promise.all returns an array of result objects. | ||
const cssRule = rules[2]; | ||
|
||
const { oneOf } = cssRule; | ||
oneOf.forEach(rule => { | ||
const { use } = rule; | ||
const allInjectTypesAreCorrect = use | ||
.filter(isStyleLoaderRule) | ||
.every(injectTypeIsStyleTag); | ||
|
||
expect(allInjectTypesAreCorrect).toBe(true); | ||
}); | ||
}); | ||
|
||
test('style loader inject type is "singletonStyleTag" not in development', async () => { | ||
// Arrange. | ||
const myHelper = { | ||
...helper, | ||
mode: 'production' | ||
}; | ||
|
||
// Act. | ||
const rules = await getModuleRules(myHelper); | ||
|
||
// Assert. | ||
// Promise.all returns an array of result objects. | ||
const cssRule = rules[2]; | ||
|
||
const { oneOf } = cssRule; | ||
oneOf.forEach(rule => { | ||
const { use } = rule; | ||
const allInjectTypesAreCorrect = use | ||
.filter(isStyleLoaderRule) | ||
.every(injectTypeIsSingletonStyleTag); | ||
|
||
expect(allInjectTypesAreCorrect).toBe(true); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.