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

test: fix deprecation warnings in tests #8642

Merged
merged 3 commits into from
Oct 20, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ describe('application-package', function (): void {
const warn = sandbox.stub(console, 'warn');
const root = createProjectWithTarget('foo');
const applicationPackage = new ApplicationPackage({ projectPath: root });
assert.equal(applicationPackage.target, ApplicationProps.ApplicationTarget.browser);
assert.equal(warn.called, true);
assert.deepStrictEqual(applicationPackage.target, ApplicationProps.ApplicationTarget.browser);
assert.deepStrictEqual(warn.called, true);
});

it('should set target from package.json', function (): void {
const target = 'electron';
const root = createProjectWithTarget(target);
const applicationPackage = new ApplicationPackage({ projectPath: root });
assert.equal(applicationPackage.target, target);
assert.deepStrictEqual(applicationPackage.target, target);
});

it('should prefer target from passed options over target from package.json', function (): void {
const pckTarget = 'electron';
const optTarget = 'browser';
const root = createProjectWithTarget(pckTarget);
const applicationPackage = new ApplicationPackage({ projectPath: root, appTarget: optTarget });
assert.equal(applicationPackage.target, optTarget);
assert.deepStrictEqual(applicationPackage.target, optTarget);
});

function createProjectWithTarget(target: string): string {
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/ext-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"theia-monorepo-scripts": {
"ext:clean": "theiaext compile:clean && theiaext lint:clean && theiaext test:clean",
"ext:build": "concurrently -n compile,lint -c blue,green \"theiaext compile\" \"theiaext lint\"",
"ext:compile": "tsc -b compile.tsconfig.json --verbose",
"ext:compile": "tsc -b compile.tsconfig.json",
"ext:compile:clean": "rimraf lib *.tsbuildinfo",
"ext:lint": "eslint --cache=true --no-error-on-unmatched-pattern=true \"{src,test}/**/*.{ts,tsx}\"",
"ext:lint:clean": "rimraf .eslintcache",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"prepare:build": "yarn build && run lint && run build \"@theia/example-*\" --stream --parallel",
"prepare:hoisting": "theia check:hoisted -s",
"clean": "yarn lint:clean && node scripts/run-reverse-topo.js yarn clean",
"build": "tsc -b configs/root-compilation.tsconfig.json --verbose",
"build": "tsc -b configs/root-compilation.tsconfig.json",
"watch": "tsc -b configs/root-compilation.tsconfig.json -w",
"lint": "run lint",
"lint:clean": "rimraf .eslintcache",
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/browser/keybinding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import { Container, injectable, ContainerModule } from 'inversify';
import { bindContributionProvider } from '../common/contribution-provider';
import { KeyboardLayoutProvider, NativeKeyboardLayout, KeyboardLayoutChangeNotifier } from '../common/keyboard/keyboard-layout-provider';
import { ILogger } from '../common/logger';
import { KeybindingRegistry, KeybindingContext, Keybinding, KeybindingContribution, KeybindingScope } from './keybinding';
import { KeybindingRegistry, KeybindingContext, KeybindingContribution, KeybindingScope } from './keybinding';
import { Keybinding } from '../common/keybinding';
import { KeyCode, Key, KeyModifier, KeySequence } from './keyboard/keys';
import { KeyboardLayoutService } from './keyboard/keyboard-layout-service';
import { CommandRegistry, CommandService, CommandContribution, Command } from '../common/command';
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/browser/tree/tree-consistency.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { createTreeTestContainer } from './test/tree-test-container';
import { TreeImpl, CompositeTreeNode, TreeNode } from './tree';
import { TreeModel } from './tree-model';
import { ExpandableTreeNode } from './tree-expansion';
import { TreeLabelProvider } from './tree-label-provider';

@injectable()
class ConsistencyTestTree extends TreeImpl {
Expand Down Expand Up @@ -72,6 +73,9 @@ describe('Tree Consistency', () => {

it('setting different tree roots should finish', async () => {
const container = createTreeTestContainer();
container.bind(TreeLabelProvider).toSelf().inSingletonScope();
const labelProvider = container.get(TreeLabelProvider);

container.bind(ConsistencyTestTree).toSelf();
container.rebind(TreeImpl).toService(ConsistencyTestTree);
const tree = container.get(ConsistencyTestTree);
Expand All @@ -90,7 +94,7 @@ describe('Tree Consistency', () => {
await new Promise(resolve => setTimeout(resolve, 50));
if (resolveCounter === tree.resolveCounter) {
assert.deepStrictEqual(tree.resolveCounter, 1);
assert.deepStrictEqual(model.root!.name, 'Bar');
assert.deepStrictEqual(labelProvider.getName(model.root)!, 'Bar');
return;
}
resolveCounter = tree.resolveCounter;
Expand Down
146 changes: 73 additions & 73 deletions packages/core/src/common/path.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,110 +22,110 @@ describe('Path', () => {

it('new from /foo/bar/file.txt', () => {
const path = new Path('/foo/bar/file.txt');
assert.deepEqual(path.isRoot, false);
assert.deepEqual(path.isAbsolute, true);
assert.deepEqual(path.root!.toString(), '/');
assert.deepEqual(path.dir.toString(), '/foo/bar');
assert.deepEqual(path.hasDir, true);
assert.deepEqual(path.base, 'file.txt');
assert.deepEqual(path.name, 'file');
assert.deepEqual(path.ext, '.txt');
assert.deepStrictEqual(path.isRoot, false);
assert.deepStrictEqual(path.isAbsolute, true);
assert.deepStrictEqual(path.root!.toString(), '/');
assert.deepStrictEqual(path.dir.toString(), '/foo/bar');
assert.deepStrictEqual(path.hasDir, true);
assert.deepStrictEqual(path.base, 'file.txt');
assert.deepStrictEqual(path.name, 'file');
assert.deepStrictEqual(path.ext, '.txt');
});

it('new from foo/bar/file.txt', () => {
const path = new Path('foo/bar/file.txt');
assert.deepEqual(path.isRoot, false);
assert.deepEqual(path.isAbsolute, false);
assert.deepEqual(path.root, undefined);
assert.deepEqual(path.dir.toString(), 'foo/bar');
assert.deepEqual(path.hasDir, true);
assert.deepEqual(path.base, 'file.txt');
assert.deepEqual(path.name, 'file');
assert.deepEqual(path.ext, '.txt');
assert.deepStrictEqual(path.isRoot, false);
assert.deepStrictEqual(path.isAbsolute, false);
assert.deepStrictEqual(path.root, undefined);
assert.deepStrictEqual(path.dir.toString(), 'foo/bar');
assert.deepStrictEqual(path.hasDir, true);
assert.deepStrictEqual(path.base, 'file.txt');
assert.deepStrictEqual(path.name, 'file');
assert.deepStrictEqual(path.ext, '.txt');
});

it('new from /foo', () => {
const path = new Path('/foo');
assert.deepEqual(path.isRoot, false);
assert.deepEqual(path.isAbsolute, true);
assert.deepEqual(path.root!.toString(), '/');
assert.deepEqual(path.dir.toString(), '/');
assert.deepEqual(path.hasDir, true);
assert.deepEqual(path.base, 'foo');
assert.deepEqual(path.name, 'foo');
assert.deepEqual(path.ext, '');
assert.deepStrictEqual(path.isRoot, false);
assert.deepStrictEqual(path.isAbsolute, true);
assert.deepStrictEqual(path.root!.toString(), '/');
assert.deepStrictEqual(path.dir.toString(), '/');
assert.deepStrictEqual(path.hasDir, true);
assert.deepStrictEqual(path.base, 'foo');
assert.deepStrictEqual(path.name, 'foo');
assert.deepStrictEqual(path.ext, '');
});

it('new from foo', () => {
const path = new Path('foo');
assert.deepEqual(path.isRoot, false);
assert.deepEqual(path.isAbsolute, false);
assert.deepEqual(path.root, undefined);
assert.deepEqual(path.dir.toString(), 'foo');
assert.deepEqual(path.hasDir, false);
assert.deepEqual(path.base, 'foo');
assert.deepEqual(path.name, 'foo');
assert.deepEqual(path.ext, '');
assert.deepStrictEqual(path.isRoot, false);
assert.deepStrictEqual(path.isAbsolute, false);
assert.deepStrictEqual(path.root, undefined);
assert.deepStrictEqual(path.dir.toString(), 'foo');
assert.deepStrictEqual(path.hasDir, false);
assert.deepStrictEqual(path.base, 'foo');
assert.deepStrictEqual(path.name, 'foo');
assert.deepStrictEqual(path.ext, '');
});

it('new from /', () => {
const path = new Path('/');
assert.deepEqual(path.isRoot, true);
assert.deepEqual(path.isAbsolute, true);
assert.deepEqual(path.root!.toString(), '/');
assert.deepEqual(path.dir.toString(), '/');
assert.deepEqual(path.hasDir, false);
assert.deepEqual(path.base, '');
assert.deepEqual(path.name, '');
assert.deepEqual(path.ext, '');
assert.deepStrictEqual(path.isRoot, true);
assert.deepStrictEqual(path.isAbsolute, true);
assert.deepStrictEqual(path.root!.toString(), '/');
assert.deepStrictEqual(path.dir.toString(), '/');
assert.deepStrictEqual(path.hasDir, false);
assert.deepStrictEqual(path.base, '');
assert.deepStrictEqual(path.name, '');
assert.deepStrictEqual(path.ext, '');
});

it('new from /c:/foo/bar/file.txt', () => {
const path = new Path('/c:/foo/bar/file.txt');
assert.deepEqual(path.isRoot, false);
assert.deepEqual(path.isAbsolute, true);
assert.deepEqual(path.root!.toString(), '/c:');
assert.deepEqual(path.dir.toString(), '/c:/foo/bar');
assert.deepEqual(path.hasDir, true);
assert.deepEqual(path.base, 'file.txt');
assert.deepEqual(path.name, 'file');
assert.deepEqual(path.ext, '.txt');
assert.deepStrictEqual(path.isRoot, false);
assert.deepStrictEqual(path.isAbsolute, true);
assert.deepStrictEqual(path.root!.toString(), '/c:');
assert.deepStrictEqual(path.dir.toString(), '/c:/foo/bar');
assert.deepStrictEqual(path.hasDir, true);
assert.deepStrictEqual(path.base, 'file.txt');
assert.deepStrictEqual(path.name, 'file');
assert.deepStrictEqual(path.ext, '.txt');
});

it('new from /c:/foo', () => {
const path = new Path('/c:/foo');
assert.deepEqual(path.isRoot, false);
assert.deepEqual(path.isAbsolute, true);
assert.deepEqual(path.root!.toString(), '/c:');
assert.deepEqual(path.dir.toString(), '/c:');
assert.deepEqual(path.hasDir, true);
assert.deepEqual(path.base, 'foo');
assert.deepEqual(path.name, 'foo');
assert.deepEqual(path.ext, '');
assert.deepStrictEqual(path.isRoot, false);
assert.deepStrictEqual(path.isAbsolute, true);
assert.deepStrictEqual(path.root!.toString(), '/c:');
assert.deepStrictEqual(path.dir.toString(), '/c:');
assert.deepStrictEqual(path.hasDir, true);
assert.deepStrictEqual(path.base, 'foo');
assert.deepStrictEqual(path.name, 'foo');
assert.deepStrictEqual(path.ext, '');
});

it('new from /c:/', () => {
const path = new Path('/c:/');
assert.deepEqual(path.isRoot, false);
assert.deepEqual(path.isAbsolute, true);
assert.deepEqual(path.root!.toString(), '/c:');
assert.deepEqual(path.dir.toString(), '/c:');
assert.deepEqual(path.hasDir, true);
assert.deepEqual(path.base, '');
assert.deepEqual(path.name, '');
assert.deepEqual(path.ext, '');
assert.deepStrictEqual(path.isRoot, false);
assert.deepStrictEqual(path.isAbsolute, true);
assert.deepStrictEqual(path.root!.toString(), '/c:');
assert.deepStrictEqual(path.dir.toString(), '/c:');
assert.deepStrictEqual(path.hasDir, true);
assert.deepStrictEqual(path.base, '');
assert.deepStrictEqual(path.name, '');
assert.deepStrictEqual(path.ext, '');
});

it('new from /c:', () => {
const path = new Path('/c:');
assert.deepEqual(path.isRoot, true);
assert.deepEqual(path.isAbsolute, true);
assert.deepEqual(path.root!.toString(), '/c:');
assert.deepEqual(path.dir.toString(), '/c:');
assert.deepEqual(path.hasDir, false);
assert.deepEqual(path.base, 'c:');
assert.deepEqual(path.name, 'c:');
assert.deepEqual(path.ext, '');
assert.deepStrictEqual(path.isRoot, true);
assert.deepStrictEqual(path.isAbsolute, true);
assert.deepStrictEqual(path.root!.toString(), '/c:');
assert.deepStrictEqual(path.dir.toString(), '/c:');
assert.deepStrictEqual(path.hasDir, false);
assert.deepStrictEqual(path.base, 'c:');
assert.deepStrictEqual(path.name, 'c:');
assert.deepStrictEqual(path.ext, '');
});

assertRelative({
Expand Down Expand Up @@ -159,7 +159,7 @@ describe('Path', () => {
}): void {
it(`the relative path from '${from}' to '${to}' should be '${expectation}'`, () => {
const path = new Path(from).relative(new Path(to));
assert.deepEqual(expectation, path && path.toString());
assert.deepStrictEqual(expectation, path && path.toString());
});
}

Expand Down
20 changes: 10 additions & 10 deletions packages/core/src/common/reference.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ describe('reference', () => {
}));
assert.ok(!references.has('a'));
assert.ok(!expectation.disposed);
assert.deepEqual(references.keys(), []);
assert.deepStrictEqual(references.keys(), []);

const reference = await references.acquire('a');
assert.ok(references.has('a'));
assert.ok(!expectation.disposed);
assert.deepEqual(references.keys(), ['a']);
assert.deepStrictEqual(references.keys(), ['a']);

reference.dispose();
assert.ok(!references.has('a'));
assert.ok(expectation.disposed);
assert.deepEqual(references.keys(), []);
assert.deepStrictEqual(references.keys(), []);
});

it('dispose 2 references', async () => {
Expand All @@ -51,23 +51,23 @@ describe('reference', () => {
}));
assert.ok(!references.has('a'));
assert.ok(!expectation.disposed);
assert.deepEqual(references.keys(), []);
assert.deepStrictEqual(references.keys(), []);

const reference = await references.acquire('a');
const reference2 = await references.acquire('a');
assert.ok(references.has('a'));
assert.ok(!expectation.disposed);
assert.deepEqual(references.keys(), ['a']);
assert.deepStrictEqual(references.keys(), ['a']);

reference.dispose();
assert.ok(references.has('a'));
assert.ok(!expectation.disposed);
assert.deepEqual(references.keys(), ['a']);
assert.deepStrictEqual(references.keys(), ['a']);

reference2.dispose();
assert.ok(!references.has('a'));
assert.ok(expectation.disposed);
assert.deepEqual(references.keys(), []);
assert.deepStrictEqual(references.keys(), []);
});

it('dispose an object with 2 references', async () => {
Expand All @@ -79,18 +79,18 @@ describe('reference', () => {
}));
assert.ok(!references.has('a'));
assert.ok(!expectation.disposed);
assert.deepEqual(references.keys(), []);
assert.deepStrictEqual(references.keys(), []);

await references.acquire('a');
const reference = await references.acquire('a');
assert.ok(references.has('a'));
assert.ok(!expectation.disposed);
assert.deepEqual(references.keys(), ['a']);
assert.deepStrictEqual(references.keys(), ['a']);

reference.object.dispose();
assert.ok(!references.has('a'));
assert.ok(expectation.disposed);
assert.deepEqual(references.keys(), []);
assert.deepStrictEqual(references.keys(), []);
});

it("shouldn't call onWillDispose event on create", async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/node/cli.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TestCliManager extends CliManager {
}

beforeEach(() => {
yargs.reset();
yargs.global([]);
});

describe('CliManager', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/node/logger-cli-contribution.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('log-level-cli-contribution', () => {
container.load(module);

cli = container.get(LogLevelCliContribution);
yargs.reset();
yargs.global([]);
cli.configure(yargs);

consoleErrorSpy = sinon.spy(console, 'error');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ describe('editor-preview-manager', () => {
});
it('should should transition the editor to permanent on pin events.', async () => {
// Fake creation call.
// eslint-disable-next-line no-unsanitized/method
await onCreateListeners.pop()!({ factoryId: EditorPreviewWidgetFactory.ID, widget: mockPreviewWidget });
// Fake pinned call
// eslint-disable-next-line no-unsanitized/method
onPinnedListeners.pop()!({ preview: mockPreviewWidget, editorWidget: mockEditorWidget });

expect(mockPreviewWidget.dispose.calledOnce).to.be.true;
Expand Down
Loading