Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use readonly in interfaces And Convert unit tests to TypeScript #788

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
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
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
"dependencies": {
"@ampproject/filesize": "^2.1.1",
"@ampproject/rollup-plugin-closure-compiler": "0.21.0",
"@babel/core": "^7.1.2",
"@babel/core": "^7.9.0",
"@babel/plugin-transform-object-assign": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.1.0",
"@babel/plugin-transform-runtime": "^7.9.0",
"@babel/preset-env": "^7.9.5",
"@babel/preset-modules": "^0.1.1",
"@babel/preset-typescript": "^7.9.0",
"@rollup/plugin-replace": "^2.2.1",
"@types/mocha": "^7.0.2",
"@typescript-eslint/eslint-plugin": "2.x",
"@typescript-eslint/parser": "2.x",
"babel-core": "^7.0.0-bridge.0",
Expand All @@ -33,9 +35,9 @@
"eslint-plugin-jsx-a11y": "6.x",
"eslint-plugin-react": "7.x",
"eslint-plugin-react-hooks": "2.x",
"expect": "^21.0.0",
"expect": "^25.3.0",
"express": "^4.17.1",
"jest-mock": "^21.0.0",
"jest-mock": "^25.3.0",
"jsonfile": "^5.0.0",
"karma": "^3.1.3",
"karma-browserstack-launcher": "^1.3.0",
Expand All @@ -45,7 +47,7 @@
"karma-mocha-reporter": "^2.2.5",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^3.0.5",
"mocha": "^5.2.0",
"mocha": "^7.1.1",
"prompt-confirm": "^2.0.4",
"rollup": "^1.27.9",
"rollup-plugin-babel": "^4.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/history/__tests__/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"mocha": true
},
"rules": {
"import/no-unresolved": [2, { "ignore": ["history"] }]
"import/no-unresolved": "off"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import expect from 'expect';

import { execSteps } from './utils.js';
import { execSteps } from './utils';

export default (history, done) => {
let hookWasCalled = false;
Expand Down Expand Up @@ -32,6 +32,7 @@ export default (history, done) => {
pathname: '/'
});

expect('action').toBe('POP');
expect(hookWasCalled).toBe(true);

unblock();
Expand Down
25 changes: 0 additions & 25 deletions packages/history/__tests__/TestSequences/BlockEverything.js

This file was deleted.

28 changes: 28 additions & 0 deletions packages/history/__tests__/TestSequences/BlockEverything.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import expect from 'expect';
import type { History } from 'history';
import type { Done } from 'mocha';

import { execSteps } from './utils';
import type { ExecSteps } from './utils';

export default (history: History, done: Done) => {
let steps: ExecSteps = [
({ location }) => {
expect(location).toMatchObject({
pathname: '/',
});

let unblock = history.block(()=>{});

history.push('/home');

expect(history.location).toMatchObject({
pathname: '/',
});

unblock();
},
];

execSteps(steps, history, done);
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import expect from 'expect';
import type { History } from 'history';
import type { Done } from 'mocha';

export default (history, done) => {
export default (history: History, done: Done) => {
expect(history.location).toMatchObject({
pathname: '/'
pathname: '/',
});

history.push('/home');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
import expect from 'expect';
import type { History } from 'history';
import type { Done } from 'mocha';

import { execSteps } from './utils.js';
import { execSteps } from './utils';
import type { ExecSteps } from './utils';

export default (history, done) => {
let steps = [
export default (history: History, done: Done) => {
let steps: ExecSteps = [
() => {
// encoded string
let pathname = '/view/%23abc';
history.replace(pathname);
},
({ location }) => {
expect(location).toMatchObject({
pathname: '/view/%23abc'
pathname: '/view/%23abc',
});
// encoded object
let pathname = '/view/%23abc';
history.replace({ pathname });
},
({ location }) => {
expect(location).toMatchObject({
pathname: '/view/%23abc'
pathname: '/view/%23abc',
});
// unencoded string
let pathname = '/view/#abc';
Expand All @@ -28,9 +31,9 @@ export default (history, done) => {
({ location }) => {
expect(location).toMatchObject({
pathname: '/view/',
hash: '#abc'
hash: '#abc',
});
}
},
];

execSteps(steps, history, done);
Expand Down
31 changes: 0 additions & 31 deletions packages/history/__tests__/TestSequences/GoBack.js

This file was deleted.

35 changes: 35 additions & 0 deletions packages/history/__tests__/TestSequences/GoBack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import expect from 'expect';
import { Action } from 'history';
import type { History } from 'history';
import type { Done } from 'mocha';

import { execSteps } from './utils';
import type { ExecSteps } from './utils';

export default (history: History, done: Done) => {
let steps: ExecSteps = [
({ location }) => {
expect(location).toMatchObject({
pathname: '/',
});

history.push('/home');
},
({ action, location }) => {
expect(action).toEqual(Action.Push);
expect(location).toMatchObject({
pathname: '/home',
});

history.back();
},
({ action, location }) => {
expect(action).toEqual(Action.Pop);
expect(location).toMatchObject({
pathname: '/',
});
},
];

execSteps(steps, history, done);
};
39 changes: 0 additions & 39 deletions packages/history/__tests__/TestSequences/GoForward.js

This file was deleted.

43 changes: 43 additions & 0 deletions packages/history/__tests__/TestSequences/GoForward.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import expect from 'expect';
import { Action } from 'history';
import type { History } from 'history';
import type { Done } from 'mocha';

import { execSteps } from './utils';
import type { ExecSteps } from './utils';

export default (history: History, done: Done) => {
let steps: ExecSteps = [
({ location }) => {
expect(location).toMatchObject({
pathname: '/',
});

history.push('/home');
},
({ action, location }) => {
expect(action).toEqual(Action.Push);
expect(location).toMatchObject({
pathname: '/home',
});

history.back();
},
({ action, location }) => {
expect(action).toEqual(Action.Pop);
expect(location).toMatchObject({
pathname: '/',
});

history.forward();
},
({ action, location }) => {
expect(action).toEqual(Action.Pop);
expect(location).toMatchObject({
pathname: '/home',
});
},
];

execSteps(steps, history, done);
};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import expect from 'expect';
import { History } from 'history';
import { Done } from 'mocha';
import { execSteps } from './utils';
import type { ExecSteps } from './utils';

export default (history: History, done: Done) => {
let steps: ExecSteps = [
({ location }) => {
expect(location.key).toBe('default');
},
];

execSteps(steps, history, done);
};
13 changes: 0 additions & 13 deletions packages/history/__tests__/TestSequences/InitialLocationHasKey.js

This file was deleted.

15 changes: 15 additions & 0 deletions packages/history/__tests__/TestSequences/InitialLocationHasKey.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import expect from 'expect';
import { History } from 'history';
import { Done } from 'mocha';
import { execSteps } from './utils';
import type { ExecSteps } from './utils';

export default (history: History, done: Done) => {
let steps: ExecSteps = [
({ location }) => {
expect(location.key).toBeTruthy();
},
];

execSteps(steps, history, done);
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import expect from 'expect';
import mock from 'jest-mock';
import { Done } from 'mocha';
import { History } from 'history';

export default (history, done) => {
export default (history: History, done: Done) => {
let spy = mock.fn();
let unlisten = history.listen(spy);

Expand Down
Loading