This repository has been archived by the owner on May 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b74fcb0
commit 23fa890
Showing
11 changed files
with
252 additions
and
205 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
2 changes: 1 addition & 1 deletion
2
...apshots__/index-style-loader.spec.js.snap → ...erver-ssr-styles-placeholder.spec.js.snap
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
54 changes: 54 additions & 0 deletions
54
packages/one-app-bundler/__tests__/webpack/loaders/styles-loader.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,54 @@ | ||
/* | ||
* Copyright 2019 American Express Travel Related Services Company, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { loadStyles } from '@americanexpress/one-app-dev-bundler'; | ||
import { BUNDLE_TYPES } from '@americanexpress/one-app-dev-bundler/esbuild/constants/enums.js'; | ||
import unboundStylesLoader from '../../../webpack/loaders/styles-loader'; | ||
|
||
jest.mock('@americanexpress/one-app-dev-bundler', () => ({ | ||
loadStyles: jest.fn(() => 'let mockJsContent = "helloMockContent"'), | ||
})); | ||
|
||
describe('styles-loader', () => { | ||
let mockGetOptions; | ||
let stylesLoader; | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
mockGetOptions = jest.fn(() => ({ | ||
cssModulesOptions: {}, | ||
bundleType: BUNDLE_TYPES.BROWSER, | ||
})); | ||
|
||
stylesLoader = unboundStylesLoader.bind({ | ||
resourcePath: 'style/path/mock.scss', | ||
getOptions: mockGetOptions, | ||
}); | ||
}); | ||
it('should call the loadStyles util with the correct params, for non-node_modules', () => { | ||
expect(stylesLoader()).toBe('let mockJsContent = "helloMockContent"'); | ||
expect(loadStyles).toHaveBeenCalledTimes(1); | ||
expect(loadStyles).toHaveBeenCalledWith({ bundleType: BUNDLE_TYPES.BROWSER, cssModulesOptions: { generateScopedName: '[local]_[hash:base64:5]' }, path: 'style/path/mock.scss' }); | ||
}); | ||
it('should call the loadStyles util with the correct params, for node_modules', () => { | ||
stylesLoader = unboundStylesLoader.bind({ | ||
resourcePath: 'node_modules/style/path/mock.scss', | ||
getOptions: mockGetOptions, | ||
}); | ||
|
||
expect(stylesLoader()).toBe('let mockJsContent = "helloMockContent"'); | ||
|
||
expect(loadStyles).toHaveBeenCalledTimes(1); | ||
expect(loadStyles).toHaveBeenCalledWith({ bundleType: BUNDLE_TYPES.BROWSER, cssModulesOptions: { generateScopedName: '[local]' }, path: 'node_modules/style/path/mock.scss' }); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
...p-bundler/__tests__/webpack/plugins/__snapshots__/server-ssr-styles-injector.spec.js.snap
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,28 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ServerSsrStylesInjectorPlugin The registered function should inject the aggregated styles into the placeholder for .node.js files 1`] = ` | ||
" | ||
// replaced | ||
ssrStyles = { | ||
aggregatedStyles: [{\\"css\\":\\"* {color: red}\\",\\"digest\\":\\"digest1Mock\\"},{\\"css\\":\\"* {color: green}\\",\\"digest\\":\\"digest2Mock\\"}], | ||
getFullSheet: function getFullSheet() { | ||
return this.aggregatedStyles.reduce((acc, { css }) => acc + css, ''); | ||
}, | ||
}; | ||
===== | ||
// replaced | ||
ssrStyles = { | ||
aggregatedStyles: [{\\"css\\":\\"* {color: red}\\",\\"digest\\":\\"digest1Mock\\"},{\\"css\\":\\"* {color: green}\\",\\"digest\\":\\"digest2Mock\\"}], | ||
getFullSheet: function getFullSheet() { | ||
return this.aggregatedStyles.reduce((acc, { css }) => acc + css, ''); | ||
}, | ||
}; | ||
===== | ||
// not replaced | ||
ssrStyles = 2574b873-59dc-4da6-8692-d767a2484dac | ||
" | ||
`; |
Oops, something went wrong.