-
Notifications
You must be signed in to change notification settings - Fork 960
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
Maxime Brazeilles
committed
Aug 6, 2024
1 parent
056c8b3
commit 6dfc0d7
Showing
2 changed files
with
79 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,49 @@ | ||
const chai = require('chai') | ||
const spies = require('chai-spies') | ||
const mjml = require('../lib') | ||
|
||
chai.use(spies) | ||
|
||
const { | ||
HeadComponent, | ||
registerComponent, | ||
} = require('../../mjml-core/lib/index') | ||
|
||
const addStyle = chai.spy( | ||
(breakpoint) => ` | ||
@media only screen and (max-width:${breakpoint}) { | ||
h1 { | ||
font-size: 20px; | ||
async function run() { | ||
chai.use(spies) | ||
|
||
const addStyle = chai.spy( | ||
(breakpoint) => ` | ||
@media only screen and (max-width:${breakpoint}) { | ||
h1 { | ||
font-size: 20px; | ||
} | ||
} | ||
} | ||
`, | ||
) | ||
`, | ||
) | ||
|
||
class HeadComponentWithFunctionStyle extends HeadComponent { | ||
handler() { | ||
const { add } = this.context | ||
add('style', addStyle) | ||
class HeadComponentWithFunctionStyle extends HeadComponent { | ||
handler() { | ||
const { add } = this.context | ||
add('style', addStyle) | ||
} | ||
} | ||
HeadComponentWithFunctionStyle.componentName = | ||
'mj-head-component-with-function-style' | ||
HeadComponentWithFunctionStyle.endingTag = true | ||
HeadComponentWithFunctionStyle.allowedAttributes = {} | ||
|
||
registerComponent(HeadComponentWithFunctionStyle) | ||
|
||
mjml(` | ||
<mjml> | ||
<mj-head> | ||
<mj-head-component-with-function-style /> | ||
<mj-breakpoint width="300px" /> | ||
</mj-head> | ||
<mj-body> | ||
</mj-body> | ||
</mjml> | ||
`) | ||
|
||
chai.expect(addStyle).to.have.been.called.with('300px') | ||
} | ||
HeadComponentWithFunctionStyle.componentName = 'mj-head-component-with-function-style' | ||
HeadComponentWithFunctionStyle.endingTag = true | ||
HeadComponentWithFunctionStyle.allowedAttributes = {} | ||
|
||
|
||
registerComponent(HeadComponentWithFunctionStyle) | ||
|
||
mjml(` | ||
<mjml> | ||
<mj-head> | ||
<mj-head-component-with-function-style /> | ||
<mj-breakpoint width="300px" /> | ||
</mj-head> | ||
<mj-body> | ||
</mj-body> | ||
</mjml> | ||
`) | ||
|
||
chai.expect(addStyle).to.have.been.called.with('300px') | ||
run() |