Skip to content

Commit

Permalink
test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mnajdova committed Apr 22, 2021
1 parent 124cf3f commit 88de62d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
9 changes: 5 additions & 4 deletions packages/react/__tests__/rehydration.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@ test('global styles can be removed individually after rehydrating SSRed HTML', (
resetAllModules()

let cache = createCache({ key: 'mui' })
let { extractCriticalToChunks, constructStyleTags } = createEmotionServer(
cache
)
let {
extractCriticalToChunks,
constructStyleTagsFromChunks
} = createEmotionServer(cache)

const rendered = ReactDOMServer.renderToString(
<CacheProvider value={cache}>
Expand All @@ -220,7 +221,7 @@ test('global styles can be removed individually after rehydrating SSRed HTML', (
const extracted = extractCriticalToChunks(rendered)
return {
app: extracted.html,
styles: constructStyleTags(extracted)
styles: constructStyleTagsFromChunks(extracted)
}
})

Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export const {
extractCriticalToChunks,
renderStylesToString,
renderStylesToNodeStream,
constructStyleTags
constructStyleTagsFromChunks
} = createEmotionServer(cache)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`extractCriticalToChunks generates correct style tags using constructStyleTags 1`] = `
exports[`extractCriticalToChunks generates correct style tags using constructStyleTagsFromChunks 1`] = `
<style data-emotion="css-global l6h">
body{color:white;}
</style>
Expand All @@ -12,7 +12,7 @@ exports[`extractCriticalToChunks generates correct style tags using constructSty
</style>
`;

exports[`extractCriticalToChunks generates correct style tags using constructStyleTags 2`] = `
exports[`extractCriticalToChunks generates correct style tags using constructStyleTagsFromChunks 2`] = `
<style data-emotion="css-global l6h">
body{color:white;}
</style>
Expand Down
10 changes: 7 additions & 3 deletions packages/server/test/extract-critical-to-chunks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ describe('extractCriticalToChunks', () => {
expect(prettifyCriticalChunks(page2Critical)).toMatchSnapshot()
})

test('generates correct style tags using constructStyleTags', () => {
expect(emotionServer.constructStyleTags(page1Critical)).toMatchSnapshot()
expect(emotionServer.constructStyleTags(page2Critical)).toMatchSnapshot()
test('generates correct style tags using constructStyleTagsFromChunks', () => {
expect(
emotionServer.constructStyleTagsFromChunks(page1Critical)
).toMatchSnapshot()
expect(
emotionServer.constructStyleTagsFromChunks(page2Critical)
).toMatchSnapshot()
})
})

0 comments on commit 88de62d

Please sign in to comment.