Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.
Closed
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
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ jobs:
- v1-dependencies-{{ checksum "./demo/package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
# run tests
- run: npm test
# build the demo
- run: cd demo && npm install
- save_cache:
Expand Down
30,963 changes: 23,250 additions & 7,713 deletions demo/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@types/uuid": "^3.4.4",
"cross-env": "^5.2.0",
"openfin-cli": "^2.0.8",
"react-scripts": "^3.3.0",
"react-scripts": "3.3.0",
"typescript": "3.4.5"
}
}
17,423 changes: 16,042 additions & 1,381 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"compile": "tsc",
"lint": "tslint src/{**,.}/*.ts{,x} demo/{**,.}/ts{,x}",
"test": "echo \"Error: no test specified\" && exit 1",
"test": "react-scripts test",
"license-validation": "npm prune --production && npm install --production && npx node-license-validator . --allow-licenses MIT Apache-2.0"
},
"repository": {
Expand All @@ -30,20 +30,26 @@
},
"homepage": "https://github.com/finos/openfin-react-hooks#readme",
"devDependencies": {
"@babel/cli": "7.8.4",
"@babel/core": "7.8.7",
"@babel/plugin-transform-typescript": "7.8.7",
"@babel/preset-env": "7.8.7",
"@testing-library/react-hooks": "3.2.1",
"@types/jest": "25.1.4",
"@types/openfin": "^41.0.0",
"@types/react": "^16.8.17",
"@types/react-dom": "^16.9.1",
"dtslint": "^2.0.5",
"husky": "^2.3.0",
"node-license-validator": "^1.3.0",
"react-scripts": "3.3.0",
"react-test-renderer": "16.13.0",
"tslint": "^5.16.0",
"typescript": "^3.4.5"
},
"peerDependencies": {
"react": "^16.8.0"
},
"dependencies": {
"openfin-layouts": "^1.0.3",
"react": "16.13.0",
"react-dom": "^16.10.1"
}
}
40 changes: 40 additions & 0 deletions src/__tests__/useDocked.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { renderHook, act } from '@testing-library/react-hooks'
import useDocked from "../../src/useDocked";
import {Fin} from "openfin/_v2/main";
import {snapAndDock} from "openfin-layouts";

jest.mock('openfin-layouts');

interface Window {
fin: Fin;
}

describe('useDocked', () => {
beforeEach(() => {
window.fin = {}; // Mock out fin object
});

it('default is not docked', () => {
const { result } = renderHook(() => useDocked());
const isDocked = result.current[0];
expect(isDocked).toBe(false);
});

it('undock function causes undock of window', () => {
const { result } = renderHook(() => useDocked());
act(() => {
result.current[0] = true; // Simulating dock by user
});

snapAndDock.undockWindow.mockImplementation(() => {
act(() => {
result.current[0] = false;
});
})

const undock = result.current[1];
undock();
const isDocked = result.current[0];
expect(isDocked).toBe(false);
});
});
1 change: 1 addition & 0 deletions src/useChildWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import getChildWindows from "./utils/helpers/getChildWindows";
import { injectNode, injectNodes } from "./utils/helpers/inject";
import { isWindowV1, isWindowV2 } from "./utils/helpers/isWindow";
import reducer, { INITIAL_WINDOW_STATE } from "./utils/reducers/WindowReducer";
import OpenFinJavaScriptAPIVersion from "./utils/types/enums/OpenFinJavaScriptAPIVersion";
import WINDOW_ACTION from "./utils/types/enums/WindowAction";
import WINDOW_STATE from "./utils/types/enums/WindowState";

Expand Down
1 change: 1 addition & 0 deletions src/utils/helpers/createWindow.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { _Window } from "openfin/_v2/api/window/window";
import { WindowOption } from "openfin/_v2/api/window/windowOption";
import OpenFinJavaScriptAPIVersion from "../types/enums/OpenFinJavaScriptAPIVersion";

const createWindowV1 = (options: WindowOption): Promise<fin.OpenFinWindow> =>
new Promise((resolve, reject) => {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/types/enums/OpenFinJavaScriptAPIVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ const enum OpenFinJavaScriptAPIVersion {
ONE,
TWO,
}

export default OpenFinJavaScriptAPIVersion;
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"src/**/*"
],
"exclude": [
"node_modules"
"node_modules",
"**/*.test.ts"
]
}
3 changes: 2 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"linterOptions": {
"exclude": [
"node_modules/**/*",
"demo/node_modules/**/*"
"demo/node_modules/**/*",
"src/__tests__/**/*"
]
}
}