Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kmjennison committed Sep 22, 2021
1 parent 4cf2cec commit 40130ea
Show file tree
Hide file tree
Showing 60 changed files with 472 additions and 459 deletions.
1 change: 0 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"bracketSpacing": true,
"jsxBracketSameLine": false,
"useTabs": false,
"semi": false,
"singleQuote": true,
Expand Down
9 changes: 5 additions & 4 deletions __mocks__/next-firebase-auth/withAuthUserSSR.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const withAuthUserSSR = jest.fn(() => (getServerSidePropsFunc) => (ctx) =>
typeof getServerSidePropsFunc === 'function'
? getServerSidePropsFunc(ctx)
: undefined
const withAuthUserSSR = jest.fn(
() => (getServerSidePropsFunc) => (ctx) =>
typeof getServerSidePropsFunc === 'function'
? getServerSidePropsFunc(ctx)
: undefined
)
export default withAuthUserSSR
4 changes: 2 additions & 2 deletions __mocks__/next-firebase-auth/withAuthUserTokenSSR.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const withAuthUserTokenSSR = jest.fn(() => (getServerSidePropsFunc) => (ctx) =>
getServerSidePropsFunc(ctx)
const withAuthUserTokenSSR = jest.fn(
() => (getServerSidePropsFunc) => (ctx) => getServerSidePropsFunc(ctx)
)
export default withAuthUserTokenSSR
7 changes: 4 additions & 3 deletions src/__tests__/e2e/e2e-tests.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ const tests = init({
})

describe('Tab: acceptance tests', () => {
tests.forEach(({ description, test, testTimeout }) =>
// eslint-disable-next-line jest/valid-title
tests.forEach(({ description, test, testTimeout }) => {
// We let the tab-e2e package make assertions.
// eslint-disable-next-line jest/valid-title, jest/expect-expect
it(description, test, testTimeout)
)
})
})
24 changes: 12 additions & 12 deletions src/__tests__/pages/_app.moduleLoad.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@ afterEach(() => {
jest.resetModules()
})

describe('_app.js: Sentry', () => {
describe('_app: Sentry', () => {
it('calls to initialize Sentry', () => {
expect.assertions(1)
const initSentry = require('src/utils/initSentry').default

// eslint-disable-next-line no-unused-expressions
require('src/pages/_app.js').default
require('src/pages/_app').default
expect(initSentry).toHaveBeenCalled()
})
})

describe('_app.js: initializes auth', () => {
describe('_app: initializes auth', () => {
it('initializes authentication on module load', () => {
expect.assertions(1)
const initAuth = require('src/utils/auth/initAuth').default
// eslint-disable-next-line no-unused-expressions
require('src/pages/_app.js').default
require('src/pages/_app').default
expect(initAuth).toHaveBeenCalledTimes(1)
})
})

describe('_app.js: tab-cmp', () => {
describe('_app: tab-cmp', () => {
it('initializes the CMP when on the client side', () => {
expect.assertions(1)
const { isClientSide } = require('src/utils/ssr')
Expand All @@ -57,7 +57,7 @@ describe('_app.js: tab-cmp', () => {
const initializeCMP = require('src/utils/initializeCMP').default

// eslint-disable-next-line no-unused-expressions
require('src/pages/_app.js').default
require('src/pages/_app').default
jest.runAllTimers()
expect(initializeCMP).toHaveBeenCalled()
})
Expand All @@ -70,18 +70,18 @@ describe('_app.js: tab-cmp', () => {
const initializeCMP = require('src/utils/initializeCMP').default

// eslint-disable-next-line no-unused-expressions
require('src/pages/_app.js').default
require('src/pages/_app').default
jest.runAllTimers()
expect(initializeCMP).not.toHaveBeenCalled()
})
})

describe('_app.js: router overrides', () => {
describe('_app: router overrides', () => {
it('sets a callback to the "routeChangeStart" router event', () => {
expect.assertions(1)
const Router = require('next/router')
// eslint-disable-next-line no-unused-expressions
require('src/pages/_app.js').default
require('src/pages/_app').default
expect(Router.events.on).toHaveBeenCalledWith(
'routeChangeStart',
expect.any(Function)
Expand All @@ -93,7 +93,7 @@ describe('_app.js: router overrides', () => {
const Router = require('next/router')
const { setWindowLocation } = require('src/utils/navigation')
// eslint-disable-next-line no-unused-expressions
require('src/pages/_app.js').default
require('src/pages/_app').default
const routeChangeStartCallback = Router.events.on.mock.calls[0][1]
expect(() => {
routeChangeStartCallback('/newtab/auth/')
Expand All @@ -108,7 +108,7 @@ describe('_app.js: router overrides', () => {
const Router = require('next/router')
const { setWindowLocation } = require('src/utils/navigation')
// eslint-disable-next-line no-unused-expressions
require('src/pages/_app.js').default
require('src/pages/_app').default
const routeChangeStartCallback = Router.events.on.mock.calls[0][1]
expect(() => {
routeChangeStartCallback('/newtab/auth/some/page/here/')
Expand All @@ -126,7 +126,7 @@ describe('_app.js: router overrides', () => {
const Router = require('next/router')
const { setWindowLocation } = require('src/utils/navigation')
// eslint-disable-next-line no-unused-expressions
require('src/pages/_app.js').default
require('src/pages/_app').default
const routeChangeStartCallback = Router.events.on.mock.calls[0][1]
expect(() => {
routeChangeStartCallback('/newtab/account/')
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/pages/_app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('_app.js', () => {

it('renders without error', () => {
expect.assertions(1)
const App = require('src/pages/_app.js').default
const App = require('src/pages/_app').default
const mockProps = getMockProps()
expect(() => {
mount(<App {...mockProps} />)
Expand All @@ -46,7 +46,7 @@ describe('_app.js', () => {
it('registers the service worker if process.env.NEXT_PUBLIC_SERVICE_WORKER_ENABLED === "true"', () => {
expect.assertions(1)
process.env.NEXT_PUBLIC_SERVICE_WORKER_ENABLED = 'true'
const App = require('src/pages/_app.js').default
const App = require('src/pages/_app').default
const mockProps = getMockProps()
mount(<App {...mockProps} />)
expect(register).toHaveBeenCalledWith('/newtab/service-worker.js')
Expand All @@ -55,7 +55,7 @@ describe('_app.js', () => {
it('unregisters the service worker if process.env.NEXT_PUBLIC_SERVICE_WORKER_ENABLED === "false"', () => {
expect.assertions(1)
process.env.NEXT_PUBLIC_SERVICE_WORKER_ENABLED = 'false'
const App = require('src/pages/_app.js').default
const App = require('src/pages/_app').default
const mockProps = getMockProps()
mount(<App {...mockProps} />)
expect(unregister).toHaveBeenCalled()
Expand All @@ -64,7 +64,7 @@ describe('_app.js', () => {
it('unregisters the service worker if process.env.NEXT_PUBLIC_SERVICE_WORKER_ENABLED is undefined', () => {
expect.assertions(1)
delete process.env.NEXT_PUBLIC_SERVICE_WORKER_ENABLED
const App = require('src/pages/_app.js').default
const App = require('src/pages/_app').default
const mockProps = getMockProps()
mount(<App {...mockProps} />)
expect(unregister).toHaveBeenCalled()
Expand Down
10 changes: 5 additions & 5 deletions src/__tests__/pages/_error.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ afterEach(() => {
describe('_error.js: render', () => {
it('renders without error', () => {
expect.assertions(1)
const ErrorPage = require('src/pages/_error.js').default
const ErrorPage = require('src/pages/_error').default
const mockProps = getMockProps()
expect(() => {
shallow(<ErrorPage {...mockProps} />)
Expand All @@ -29,7 +29,7 @@ describe('_error.js: render', () => {

it('returns the ErrorPageComponent', () => {
expect.assertions(1)
const ErrorPage = require('src/pages/_error.js').default
const ErrorPage = require('src/pages/_error').default
const wrapper = shallow(<ErrorPage />)
expect(wrapper.at(0).type()).toEqual(ErrorPageComponent)
})
Expand All @@ -39,7 +39,7 @@ describe('_error.js: getInitialProps', () => {
it('returns the status code when called server-side', async () => {
expect.assertions(1)
const otherMockErr = new Error('Another error.')
const ErrorPage = require('src/pages/_error.js').default
const ErrorPage = require('src/pages/_error').default
const initialProps = await ErrorPage.getInitialProps({
res: { ...getMockRes(), statusCode: 403 },
err: otherMockErr,
Expand All @@ -54,7 +54,7 @@ describe('_error.js: getInitialProps', () => {
expect.assertions(1)
const otherMockErr = new Error('Another error.')
otherMockErr.statusCode = 500
const ErrorPage = require('src/pages/_error.js').default
const ErrorPage = require('src/pages/_error').default
const initialProps = await ErrorPage.getInitialProps({
res: undefined, // not server-side
err: otherMockErr,
Expand All @@ -67,7 +67,7 @@ describe('_error.js: getInitialProps', () => {

it('returns a 404 status code when called client-side with no error', async () => {
expect.assertions(1)
const ErrorPage = require('src/pages/_error.js').default
const ErrorPage = require('src/pages/_error').default
const initialProps = await ErrorPage.getInitialProps({
res: undefined, // not server-side
err: undefined, // no provided error
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/pages/account.moduleLoad.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('account.js: HOC', () => {
it('calls `withAuthUser`, with a render/redirect-if-unauthed strategy', () => {
expect.assertions(1)
const { withAuthUser, AuthAction } = require('next-firebase-auth')
const AccountPage = require('src/pages/account.js').default
const AccountPage = require('src/pages/account').default
const mockProps = getMockProps()
shallow(<AccountPage {...mockProps} />)
expect(withAuthUser).toHaveBeenCalledWith({
Expand All @@ -32,7 +32,7 @@ describe('account.js: HOC', () => {
it('calls `withRelay`', () => {
expect.assertions(1)
const withRelay = require('src/utils/pageWrappers/withRelay').default
const AccountPage = require('src/pages/account.js').default
const AccountPage = require('src/pages/account').default
const mockProps = getMockProps()
shallow(<AccountPage {...mockProps} />)
expect(withRelay).toHaveBeenCalled()
Expand All @@ -42,7 +42,7 @@ describe('account.js: HOC', () => {
describe('account.js: getServerSideProps', () => {
it('does not define getServerSideProps', () => {
expect.assertions(1)
const { getServerSideProps } = require('src/pages/account.js')
const { getServerSideProps } = require('src/pages/account')
expect(getServerSideProps).toBeUndefined()
})
})
Loading

0 comments on commit 40130ea

Please sign in to comment.