Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
chore(jest): update jest and fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dogpatch626 committed Nov 13, 2023
1 parent a3ff044 commit be994bd
Show file tree
Hide file tree
Showing 20 changed files with 132 additions and 126 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@babel/core": "^7.9.6",
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"amex-jest-preset": "^7.0.0",
"amex-jest-preset-react": "^6.1.0",
"babel-jest": "^26.1.0",
"babel-preset-amex": "^2.1.0",
Expand All @@ -43,7 +44,8 @@
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-jest-dom": "^4.0.1",
"husky": "^4.0.10",
"jest": "^25.1.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lerna": "^3.22.1",
"lockfile-lint": "^4.1.0",
"prettier": "^2.8.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ HolocronModuleRegisterPlugin.prototype.apply = function apply(compiler) {
// descend into the source and inject the registration within the iife
// The last two symbols are always the closing of the iife, then a `;`
// Therefore, insert the registration immediately before the iife closes
// eslint-disable-next-line no-underscore-dangle, max-len -- webpack
// eslint-disable-next-line no-underscore-dangle -- webpack
source._source._children.splice(-2, 0, `;Holocron.registerModule("${moduleName}", ${holocronModuleName});`);

Check failure on line 38 in packages/holocron-module-register-webpack-plugin/HolocronModuleRegisterPlugin.js

View workflow job for this annotation

GitHub Actions / Node 16.x

This line has a length of 120. Maximum allowed is 100
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('HolocronModuleRegisterPlugin', () => {
expect(fileContents.startsWith('/******/ (() => { // webpackBootstrap')).toBe(true);
expect(fileContents).toContain('const ModuleWithAsyncImport = () =>');
expect(fileContents).toContain('Holocron.registerModule("some-module", SomeModule);');
// eslint-disable-next-line max-len -- long assignment

const asyncChunkContents = fs.readFileSync(path.join(buildPath, `async-import.${outputFileName}`)).toString();

Check failure on line 115 in packages/holocron-module-register-webpack-plugin/__tests__/HolocronModuleRegisterPlugin.spec.js

View workflow job for this annotation

GitHub Actions / Node 16.x

This line has a length of 114. Maximum allowed is 100
expect(asyncChunkContents).toContain('() => \'Hello, world\'');
expect(asyncChunkContents).not.toContain('Holocron.registerModule("some-module"');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ModuleRouteUtils addToRouteProps should add props and replace old props with new ones 1`] = `
Object {
"props": Object {
{
"props": {
"changed": "new",
"new": "prop",
"unchanged": "value",
Expand All @@ -12,21 +12,21 @@ Object {
`;

exports[`ModuleRouteUtils createModuleRoute getChildRoutes should get the child routes 1`] = `
Array [
Object {
[
{
"indexRoute": "index",
"moduleName": "another-module",
"path": "another",
"props": Object {
"store": Object {
"props": {
"store": {
"dispatch": [MockFunction] {
"calls": Array [
Array [
"calls": [
[
Promise {},
],
],
"results": Array [
Object {
"results": [
{
"type": "return",
"value": Promise {},
},
Expand All @@ -39,9 +39,9 @@ Array [
`;

exports[`ModuleRouteUtils createModuleRoute getComponent should get the module 1`] = `
Object {
"childRoutes": Array [
Object {
{
"childRoutes": [
{
"indexRoute": "index",
"moduleName": "another-module",
"path": "another",
Expand All @@ -51,7 +51,7 @@ Object {
`;

exports[`ModuleRouteUtils createModuleRoute should create a valid module route 1`] = `
Object {
{
"default": "value",
"getChildRoutes": [Function],
"getComponent": [Function],
Expand All @@ -64,17 +64,17 @@ Object {
`;

exports[`ModuleRouteUtils createModuleRoute should not add moduleRoute props if no moduleName is present 1`] = `
Object {
{
"default": "value",
"hello": "world",
"title": "test",
}
`;

exports[`ModuleRouteUtils createModuleRouteFromElement should convert a jsx ModuleRoute to a valid module route 1`] = `
Object {
"childRoutes": Array [
Object {
{
"childRoutes": [
{
"getChildRoutes": [Function],
"getComponent": [Function],
"getIndexRoute": [Function],
Expand All @@ -98,7 +98,7 @@ Object {
`;

exports[`ModuleRouteUtils createModuleRouteFromElement should not add childRoutes if the only children are not valid elements 1`] = `
Object {
{
"getChildRoutes": [Function],
"getComponent": [Function],
"getIndexRoute": [Function],
Expand All @@ -111,26 +111,26 @@ Object {
`;

exports[`ModuleRouteUtils passChildrenProps should pass props to children 1`] = `
Array [
Object {
"props": Object {
[
{
"props": {
"hello": "world",
},
},
]
`;

exports[`ModuleRouteUtils passChildrenProps should pass the store to a function that creates routes 1`] = `
Array [
Object {
"props": Object {
[
{
"props": {
"state": "Hello world",
"store": Object {
"store": {
"getState": [Function],
},
},
},
]
`;

exports[`ModuleRouteUtils passChildrenProps should return an empty array if no routes are provided 1`] = `Array []`;
exports[`ModuleRouteUtils passChildrenProps should return an empty array if no routes are provided 1`] = `[]`;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`RenderModule should pass children to the module 1`] = `
<RenderModule
moduleName="my-test-module"
props={Object {}}
props={{}}
>
<MyTestModule>
<div>
Expand All @@ -20,7 +20,7 @@ exports[`RenderModule should pass props to the module 1`] = `
<RenderModule
moduleName="my-test-module"
props={
Object {
{
"foo": "bar",
"hello": "world",
}
Expand All @@ -43,7 +43,7 @@ exports[`RenderModule should pass props to the module 1`] = `
exports[`RenderModule should render a module 1`] = `
<RenderModule
moduleName="my-test-module"
props={Object {}}
props={{}}
>
<MyTestModule>
<div>
Expand All @@ -54,8 +54,8 @@ exports[`RenderModule should render a module 1`] = `
`;

exports[`RenderModule should warn and render null when it cannot find a module in registry 1`] = `
Array [
Array [
[
[
"Module not-in-module-map was not found in the holocron module registry",
],
]
Expand All @@ -64,13 +64,13 @@ Array [
exports[`RenderModule should warn and render null when it cannot find a module in registry 2`] = `
<RenderModule
moduleName="not-in-module-map"
props={Object {}}
props={{}}
/>
`;

exports[`RenderModule should warn and render null when module is not loaded 1`] = `
Array [
Array [
[
[
"Module not-in-module-map was not found in the holocron module registry",
],
]
Expand All @@ -79,6 +79,6 @@ Array [
exports[`RenderModule should warn and render null when module is not loaded 2`] = `
<RenderModule
moduleName="not-in-module-map"
props={Object {}}
props={{}}
/>
`;
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`holocronModule executeLoadModuleData should call loadModuleData with correct args 1`] = `
Array [
Array [
Object {
[
[
{
"fetchClient": [MockFunction],
"module": Object {
"module": {
"displayName": "FakeComponent",
},
"ownProps": Object {},
"store": Object {
"ownProps": {},
"store": {
"dispatch": [MockFunction] {
"calls": Array [
Array [
"calls": [
[
[Function],
],
],
"results": Array [
Object {
"results": [
{
"type": "return",
"value": Promise {},
},
Expand Down Expand Up @@ -66,8 +66,8 @@ exports[`holocronModule should provide the module state as a plain JS prop if a
`;

exports[`holocronModule should warn if a reducer is set but no name 1`] = `
Array [
Array [
[
[
"The Holocron Config in 'HolocronModule(undefined)' requires a 'name' when passing a 'reducer'.
The 'reducer' will not be added to the Redux Store without a 'name'.",
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`public API should not have anything removed 1`] = `
Object {
{
"RenderModule": [Function],
"clearModulesUsingExternals": [Function],
"composeModules": [Function],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Retrying (3)..."
`;

exports[`loadModule.node loading a module retries 4`] = `
"Holocron module \\"awesome\\" at \\"https://example.com/cdn/awesome/1.0.0/awesome.node.js\\" failed to execute.
[Error Message]: \\"test error, like a socket disconnect\\"
"Holocron module "awesome" at "https://example.com/cdn/awesome/1.0.0/awesome.node.js" failed to execute.
[Error Message]: "test error, like a socket disconnect"
Please fix any errors and wait for it to be reloaded."
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exports[`moduleRegistry should maintain a block list 2`] = `"https://example.com

exports[`moduleRegistry should register modules 1`] = `
Immutable.Map {
"good-module": Object {
"good-module": {
"$$typeof": Symbol(react.memo),
"WrappedComponent": [Function],
"compare": null,
Expand All @@ -22,7 +22,7 @@ Immutable.Map {
`;

exports[`moduleRegistry should register modules 2`] = `
Object {
{
"$$typeof": Symbol(react.memo),
"WrappedComponent": [Function],
"compare": null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`publicHolocronModule should add holocron config properties to component 1`] = `
Object {
{
"displayName": "FakeComponent",
"holocron": Object {
"holocron": {
"load": [Function],
"loadModuleData": [Function],
"mergeProps": [Function],
Expand All @@ -17,9 +17,9 @@ Object {
`;

exports[`publicHolocronModule should attach empty holocron config to component without args 1`] = `
Object {
{
"displayName": "FakeComponent",
"holocron": Object {},
"holocron": {},
"name": "FakeComponent",
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ Immutable.Map {
`;

exports[`updateModuleRegistry should resolve with the new versions of the changed modules 1`] = `
Object {
"another-module": Object {
"browser": Object {
{
"another-module": {
"browser": {
"integrity": "7764",
"url": "https://example.com/cdn/another-module/2.5.6/another-module.browser.js",
},
"legacyBrowser": Object {
"legacyBrowser": {
"integrity": "34566",
"url": "https://example.com/cdn/another-module/2.5.6/another-module.legacy.browser.js",
},
"node": Object {
"node": {
"integrity": "4556",
"url": "https://example.com/cdn/another-module/2.5.6/another-module.node.js",
},
Expand All @@ -37,17 +37,17 @@ Object {
`;

exports[`updateModuleRegistry should resolve with the new versions of the changed modules if the current module registry is empty 1`] = `
Object {
"another-module": Object {
"browser": Object {
{
"another-module": {
"browser": {
"integrity": "7764",
"url": "https://example.com/cdn/another-module/2.5.6/another-module.browser.js",
},
"legacyBrowser": Object {
"legacyBrowser": {
"integrity": "34566",
"url": "https://example.com/cdn/another-module/2.5.6/another-module.legacy.browser.js",
},
"node": Object {
"node": {
"integrity": "4556",
"url": "https://example.com/cdn/another-module/2.5.6/another-module.node.js",
},
Expand Down Expand Up @@ -107,8 +107,8 @@ Immutable.Map {
`;

exports[`updateModuleRegistry should update the modules in the registry: modules 1`] = `
Object {
"another-module": Object {
{
"another-module": {
"$$typeof": Symbol(react.memo),
"WrappedComponent": [Function],
"compare": null,
Expand Down
Loading

0 comments on commit be994bd

Please sign in to comment.