Skip to content

Commit eedae60

Browse files
committed
Update deps and fix lint issues
1 parent b899fb8 commit eedae60

22 files changed

+1367
-1617
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lib/**
2+
coverage/**

__tests__/.eslintrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
22
"env": {
3-
"mocha": true
3+
"jest": true
4+
},
5+
"rules": {
6+
"global-require": ["off"],
7+
"react/jsx-filename-extension": ["off"]
48
}
59
}

__tests__/ReactHTMLEmail.test.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,24 @@ describe('ReactHTMLEmail', () => {
1111

1212
describe('PropTypes.style', () => {
1313
it('returns an error for non-objects', () => {
14-
const spy = spyOn(console, 'error')
14+
const spy = jest.spyOn(console, 'error').mockImplementation()
1515
const style = 1
1616
checkPropTypes(module.PropTypes, { style }, 'style', 'Test')
1717
expect(spy).toHaveBeenCalled()
1818
expect(spy).toHaveBeenCalledWith('Warning: Failed style type: Invalid style `style` of type `number` supplied to `Test`, expected `object`.')
1919
})
2020

2121
it('validates style objects', () => {
22-
const spy = spyOn(module.default.__styleValidator, 'validate')
22+
const spy = jest.spyOn(module.default.styleValidator, 'validate').mockImplementation()
2323
const style = { listStylePosition: '11px' }
2424
checkPropTypes(module.PropTypes, { style }, 'style', 'Test')
2525
expect(spy).toHaveBeenCalledWith(style, 'Test')
2626
})
2727
})
2828

2929
describe('configStyleValidator', () => {
30-
beforeEach(() => {
31-
const module = require('../src/index')
32-
})
33-
3430
it('updates StyleValidator config', () => {
35-
const spy = spyOn(module.default.__styleValidator, 'setConfig')
31+
const spy = jest.spyOn(module.default.styleValidator, 'setConfig').mockImplementation()
3632
const config = { strict: false }
3733
module.configStyleValidator(config)
3834
expect(spy).toHaveBeenCalledWith(config)
@@ -48,7 +44,7 @@ describe('ReactHTMLEmail', () => {
4844
})
4945

5046
it('disables warnings', () => {
51-
expect(module.default.__styleValidator.config.warn).toEqual(false)
47+
expect(module.default.styleValidator.config.warn).toEqual(false)
5248
})
5349

5450
afterAll(() => {

__tests__/StyleValidator.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ describe('StyleValidator', () => {
3939

4040
it('does not return an error on a known property, but warns with comments', () => {
4141
const val = new StyleValidator({ platforms: ['gmail-android', 'yahoo-mail'] })
42-
const spy = spyOn(console, 'warn')
42+
const spy = jest.spyOn(console, 'warn').mockImplementation()
4343
const result = val.validate({ backgroundSize: '11px' }, '<Test>')
4444
expect(spy).toHaveBeenCalledWith('Warning: Style property `background-size` supplied to `<Test>`, in gmail-android, yahoo-mail: image not stretched')
4545
expect(result).toBe(undefined)
4646
})
4747

4848
it('does not output warnings when they are disabled', () => {
4949
const val = new StyleValidator({ warn: false, platforms: ['gmail-android', 'yahoo-mail'] })
50-
const spy = spyOn(console, 'warn')
50+
const spy = jest.spyOn(console, 'warn').mockImplementation()
5151
const result = val.validate({ backgroundSize: '11px' }, '<Test>')
5252
expect(spy).not.toHaveBeenCalled()
5353
expect(result).toBe(undefined)

__tests__/injectReactEmailAttributes.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('injectReactEmailAttributes', () => {
66
beforeAll(() => {
77
jest.resetModules()
88
const module = require('../src/injectReactEmailAttributes')
9-
DOMProperty = module._DOMProperty
9+
DOMProperty = module.DOMProperty
1010
injectReactEmailAttributes = module.default
1111
emailAttributes = module.emailAttributes
1212
})
@@ -16,13 +16,13 @@ describe('injectReactEmailAttributes', () => {
1616
})
1717

1818
it('injects email properties on first run', () => {
19-
const spy = spyOn(DOMProperty.injection, 'injectDOMPropertyConfig')
19+
const spy = jest.spyOn(DOMProperty.injection, 'injectDOMPropertyConfig').mockImplementation()
2020
injectReactEmailAttributes()
2121
expect(spy).toHaveBeenCalledWith(emailAttributes)
2222
})
2323

2424
it('no-ops on second run', () => {
25-
const spy = spyOn(DOMProperty.injection, 'injectDOMPropertyConfig')
25+
const spy = jest.spyOn(DOMProperty.injection, 'injectDOMPropertyConfig').mockImplementation()
2626
injectReactEmailAttributes()
2727
expect(spy).not.toHaveBeenCalled()
2828
})

__tests__/renderEmail.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import kitchenSink from '../examples/kitchenSink'
21
import React from 'react'
2+
import kitchenSink from '../examples/kitchenSink'
33
import { A } from '../src/index'
44

55
describe('renderEmail', () => {
@@ -15,12 +15,12 @@ describe('renderEmail', () => {
1515

1616
it('produces expected output from a kitchen sink example', () => {
1717
const actualOutput = renderEmail(kitchenSink)
18-
const expectedOutput = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Test Email</title><style type="text/css">@media only screen and (max-device-width: 480px) {\n font-size: 20px !important;\n}</style></head><body style="width:100%;margin:0;padding:0;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;"><table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0" align="left" valign="top"><tbody><tr><td align="center" valign="top"><table width="600" align="center" cellpadding="0" cellspacing="0" border="0" valign="top"><tbody><tr><td><span style="font-family:sans-serif;font-size:15px;line-height:15px;color:#000;">Hello, world!</span></td></tr><tr><td><table cellspacing="20" width="100%" style="border-top:3px solid black;" cellpadding="0" border="0" align="left" valign="top"><tbody><tr><td><span style="font-family:sans-serif;font-size:14px;line-height:20px;color:gray;">Generated by <a href="https://github.com/chromakode/react-html-email" target="_blank" style="text-decoration:underline;">react-html-email</a></span><img data-mc-bar="bar" data-mc-baz="baz" alt="react" src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/57/React.js_logo.svg/100px-React.js_logo.svg.png" width="100" height="100" style="display:block;outline:none;border:none;text-decoration:none;"/><a download="https://raw.githubusercontent.com/chromakode/react-html-email/master/examples/kitchenSink.js" href="https://raw.githubusercontent.com/chromakode/react-html-email/master/examples/kitchenSink.js" target="_blank" style="text-decoration:underline;">Source code</a></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></body></html>'
18+
const expectedOutput = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Test Email</title><style type="text/css">@media only screen and (max-device-width: 480px) {\n font-size: 20px !important;\n}</style></head><body style="width:100%;margin:0;padding:0;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;"><table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0" align="left" valign="top"><tbody><tr><td align="center" valign="top"><table width="600" align="center" cellpadding="0" cellspacing="0" border="0" valign="top"><tbody><tr><td><span style="font-family:sans-serif;font-size:15px;line-height:15px;color:#000;">Hello, world!</span></td></tr><tr><td><table cellspacing="20" width="100%" style="border-top:3px solid black;" cellpadding="0" border="0" align="left" valign="top"><tbody><tr><td><span style="font-family:sans-serif;font-size:14px;line-height:20px;color:gray;">Generated by <a href="https://github.com/chromakode/react-html-email" target="_blank" style="text-decoration:underline;">react-html-email</a></span><img data-mc-bar="bar" data-mc-baz="baz" alt="react" src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/57/React.js_logo.svg/100px-React.js_logo.svg.png" width="100" height="100" style="display:block;outline:none;border:none;text-decoration:none;"/><a download="https://raw.githubusercontent.com/chromakode/react-html-email/master/examples/kitchenSink.js" href="https://raw.githubusercontent.com/chromakode/react-html-email/master/examples/kitchenSink.js" target="_blank" style="text-decoration:underline;">Source code</a></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></body></html>'
1919
expect(actualOutput).toBe(expectedOutput)
2020
})
2121

2222
it('warns on usage of an unsupported property', () => {
23-
const spy = spyOn(console, 'error')
23+
const spy = jest.spyOn(console, 'error').mockImplementation()
2424
const actualOutput = renderEmail(<A href="#test" style={{ listStylePosition: 'inside' }} />)
2525
const expectedOutput = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><a href="#test" target="_blank" style="text-decoration:underline;list-style-position:inside;"></a>'
2626
expect(actualOutput).toBe(expectedOutput)
File renamed without changes.

0 commit comments

Comments
 (0)