Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,9 @@ jobs:
- name: Test package platform
working-directory: platform
run: node ../cli/index.js test
- name: Collect coverage for platform
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
fail_ci_if_error: true
flags: unittests
file: platform/coverage/clover.xml
- name: Test package bootstrap
working-directory: bootstrap
run: node ../cli/index.js test
- name: Collect coverage for bootstrap
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
fail_ci_if_error: true
flags: unittests
file: bootstrap/coverage/clover.xml

lint:
name: Lint
Expand Down
1 change: 0 additions & 1 deletion bootstrap/src/component/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const DEFAULT_LOCALE = "en-US";
const FullyInitializedGate = (props) => {
const initialized = useSelector(getIsInitialized);
const locale = useSelector(getLanguage);
/* istanbul ignore next */
if (!initialized || !locale) {
return null;
}
Expand Down
1 change: 0 additions & 1 deletion bootstrap/src/reducer/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* istanbul ignore file */
import localisationReducer from "./localisation";
import runtimeReducer from "./runtime";

Expand Down
4 changes: 4 additions & 0 deletions bootstrap/src/reducer/localisation.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/* c8 ignore start */
import * as constants from "../constants";

const initialState = {
language: null,
messages: {},
};
/* c8 ignore stop */

function createLocalisationReducer() {
const localeMapping = {};
Expand Down Expand Up @@ -80,6 +82,8 @@ function createLocalisationReducer() {
};
}

/* c8 ignore start */
export { initialState };

export default createLocalisationReducer();
/* c8 ignore stop */
1 change: 0 additions & 1 deletion bootstrap/src/saga/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* istanbul ignore file */
import { watchBootstrap } from "./bootstrap";
import { watchRefresh, watchFetchContext } from "./context";
import { watchModules, watchChangeLanguage } from "./localisation";
Expand Down
4 changes: 1 addition & 3 deletions bootstrap/src/saga/localisation.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { getLanguage } from "../selector";
const availableLocales = {};
const loadedLocales = {};

/* istanbul ignore next */
export async function downloadBatchLocales(names, language) {
const scheduledAssets = [];
for (const name of names) {
Expand Down Expand Up @@ -55,7 +54,6 @@ export function* watchModules() {
const action = yield take(backlog);

if (action.type === constants.SET_AVAILABLE_MODULES) {
/* istanbul ignore next */
for (const key in availableLocales) {
delete availableLocales[key];
}
Expand Down Expand Up @@ -103,7 +101,7 @@ export function* watchChangeLanguage() {
const language = action.payload.language;

const missing = [];
/* istanbul ignore next */

for (const name in loadedLocales) {
if (loadedLocales[name][language]) {
continue;
Expand Down
36 changes: 29 additions & 7 deletions jest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,31 @@ module.exports = {
verbose: true,
collectCoverage: true,
testEnvironment: "jsdom",
coverageDirectory: "<rootDir>/reports",
coverageReporters: ["text", "json", "lcov", "clover"],
collectCoverageFrom: ["src/**/*.{js,ts,jsx,tsx}"],
coverageProvider: "v8",
coverageReporters: ["none"],
collectCoverageFrom: ["**/*.{js,ts,jsx,tsx}"],
reporters: [
"default",
[
"jest-monocart-coverage",
{
name: "Jest Coverage Report",
outputDir: path.join(".", path.relative(".", process.env.INIT_CWD), "reports", "ut-coverage"),
entryFilter: {
"**/node_modules/**": false,
"**/*": true,
},
sourceFilter: {
"**/node_modules/**": false,
"**/**": true,
},
sourcePath: (filePath, info) => {
return info.distFile ?? filePath;
},
reports: ["text", "v8", "raw"],
},
],
],
moduleFileExtensions: ["js", "ts", "jsx", "tsx"],
transform: {
"\\.[t|j]sx?$": [
Expand All @@ -49,10 +71,10 @@ module.exports = {
],
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
branches: 0,
functions: 0,
lines: 0,
statements: 0,
},
},
moduleDirectories: [...node_modules, "<rootDir>/src"],
Expand Down
84 changes: 84 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lastui/rocker",
"version": "0.20.46",
"version": "0.20.47",
"license": "Apache-2.0",
"author": "jan.cajthaml@gmail.com",
"homepage": "https://github.com/lastui/rocker#readme",
Expand Down Expand Up @@ -46,8 +46,8 @@
"postbuild:platform:prod": "node --no-deprecation ./platform/scripts/unlink.mjs",
"lint": "node --no-deprecation ./cli/index.js lint",
"test": "npm run test:platform && npm run test:bootstrap",
"test:bootstrap": "node --no-deprecation ./cli/index.js test --cwd=bootstrap --debug",
"test:platform": "node --no-deprecation ./cli/index.js test --cwd=platform --debug"
"test:bootstrap": "node --no-deprecation ./cli/index.js test --cwd=bootstrap",
"test:platform": "node --no-deprecation ./cli/index.js test --cwd=platform"
},
"dependencies": {
"@babel/core": "7.26.0",
Expand Down Expand Up @@ -80,6 +80,7 @@
"html-webpack-plugin": "5.6.3",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"jest-monocart-coverage": "1.1.1",
"json5-loader": "4.0.1",
"mini-css-extract-plugin": "2.9.2",
"npm-registry-fetch": "18.0.2",
Expand Down
3 changes: 2 additions & 1 deletion platform/src/component/Module.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ const Module = forwardRef((props, ref) => {
useEffect(() => {
const controller = new AbortController();

/* istanbul ignore next */
moduleLoader.loadModule(props.name, controller).then((changed) => {
/* c8 ignore next 3 */
if (controller.signal.aborted) {
return;
}

/* c8 ignore next 3 */
if (changed) {
setLastLocalUpdate((tick) => (tick + 1) % Number.MAX_SAFE_INTEGER);
}
Expand Down
1 change: 0 additions & 1 deletion platform/src/kernel/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import "regenerator-runtime/runtime";

/* istanbul ignore file */
import Module from "../component/Module";
import * as constants from "../constants";
import registerModule from "../register";
Expand Down
3 changes: 2 additions & 1 deletion platform/src/kernel/middleware/saga.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ const createSagaMiddleware = (options = {}) => {
type: effect.type,
});
}
/* istanbul ignore next */
/* v8 ignore start */
if (process.env.NODE_ENV === "development") {
warning("Saga TAKE pattern function is not supported", effect);
}
/* v8 ignore stop */
return;
}
case "PUT": {
Expand Down
4 changes: 4 additions & 0 deletions platform/src/kernel/reducer/__tests__/env.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import reducer, { initialState } from "../env";

describe("env reducer", () => {
describe("is reducer", () => {
it("is function", () => {
expect(typeof reducer).toEqual("function");
});
it("has initial state", () => {
const action = {
type: "non-handled",
};
expect(initialState).toBeDefined();
expect(reducer(undefined, action)).toEqual(initialState);
});
it("has default case", () => {
Expand Down
4 changes: 4 additions & 0 deletions platform/src/kernel/reducer/__tests__/modules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@ describe("modules reducer", () => {
});

describe("is reducer", () => {
it("is function", () => {
expect(typeof reducer).toEqual("function");
});
it("has initial state", () => {
const action = {
type: "non-handled",
};
expect(initialState).toBeDefined();
expect(reducer(undefined, action)).toEqual(initialState);
});

Expand Down
4 changes: 4 additions & 0 deletions platform/src/kernel/reducer/__tests__/shared.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ describe("shared reducer", () => {
});

describe("is reducer", () => {
it("is function", () => {
expect(typeof reducer).toEqual("function");
});
it("has initial state", () => {
const action = {
type: "non-handled",
};
expect(initialState).toBeDefined();
expect(reducer(undefined, action)).toEqual(initialState);
});
it("has default case", () => {
Expand Down
Loading