Skip to content

Commit

Permalink
Fix TypeScript issues in tests (#8370)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zyie committed Jun 1, 2022
1 parent be5acab commit 8153970
Show file tree
Hide file tree
Showing 132 changed files with 3,496 additions and 2,925 deletions.
28 changes: 27 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"extends": ["@pixi/eslint-config"],
"plugins": ["jsdoc"],
"parserOptions": {
"project": ["./tsconfig.eslint.json"]
},
"ignorePatterns": ["**/*.index.d.ts"],
"settings": {
"jsdoc": {
"mode": "typescript",
Expand Down Expand Up @@ -59,5 +63,27 @@
"jsdoc/require-returns-description": 1,
"jsdoc/tag-lines": 1,
"jsdoc/valid-types": 1
}
},
"overrides": [
{
"files": ["*.tests.ts", "*.test.ts"],
"globals": {
"expect": false,
"assert": false,
"sinon": false
},
"rules": {
"@typescript-eslint/no-unused-expressions": 0,
"@typescript-eslint/dot-notation": [
0,
{
"allowPrivateClassPropertyAccess": true,
"allowProtectedClassPropertyAccess": true,
"allowIndexSignaturePropertyAccess": true
}
],
"dot-notation": 0
}
}
]
}
17 changes: 0 additions & 17 deletions .eslintrc.tests.json

This file was deleted.

112 changes: 90 additions & 22 deletions package-lock.json

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

17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,25 @@
"clean:modules": "lerna clean --yes",
"clean": "run-s clean:*",
"floss": "cross-env TS_NODE_PROJECT=tsconfig.tests.json floss -r ts-node/register/transpile-only -p test",
"test": "run-s lint:tests floss",
"test": "run-s floss",
"unit-test": "npm run floss -- --",
"unit-test:debug": "npm run floss -- --debug --",
"precoverage": "run-s lint:tests",
"precoverage": "run-s lint",
"coverage": "nyc run-s floss && nyc report --reporter=html",
"coverage:ci": "run-s coverage && nyc report --reporter=text-lcov > coverage.lcov",
"docs": "mkdirp dist && webdoc -R README.md",
"lint:src": "eslint --ext .js --ext .ts test bundles packages scripts --ignore-path .gitignore --ignore-pattern \"**/*.tests.ts\" --max-warnings 0",
"lint:tests": "eslint -c .eslintrc.tests.json --ext .ts \"**/*.tests.ts\" --max-warnings 0",
"lint": "run-s lint:*",
"lintfix": "run-s \"lint:* -- --fix\"",
"lint": "eslint --ext .js --ext .ts test bundles packages scripts --ignore-path .gitignore --max-warnings 0",
"lintfix": "run-s \"lint -- --fix\"",
"types": "tsc -noEmit",
"build": "run-s clean:build build:dev",
"build:prod": "cross-env NODE_ENV=production rollup -c",
"build:dev": "rollup -c",
"build:types": "rimraf out && tsc && api-extractor-lerna-monorepo && rimraf out && ts-node-script ./scripts/injectGlobalMixins.ts",
"watch": "rollup -cw",
"dist": "run-s lint:src types build:prod build:types docs",
"dist": "run-s lint types build:prod build:types docs",
"postdist": "copyfiles -f bundles/*/dist/browser/* dist && copyfiles -f \"packages/**/dist/browser/*\" dist/packages",
"prerelease": "run-s clean:build test",
"postversion": "run-s lint:src types build:prod build:types",
"postversion": "run-s lint types build:prod build:types",
"release": "lerna version --exact --force-publish",
"version": "ts-node scripts/fixPeerVersions.ts && npx --yes npm@7.20.2 i --package-lock-only && git add package-lock.json",
"prepublish-ci": "run-s build:types",
Expand Down Expand Up @@ -73,7 +71,10 @@
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-typescript": "^6.0.0",
"@types/chai": "^4.3.1",
"@types/mocha": "^8.2.3",
"@types/sinon": "^10.0.11",
"@types/sinon-chai": "^3.2.8",
"@webdoc/cli": "^1.5.5",
"chai": "~4.3.6",
"copyfiles": "^2.1.0",
Expand Down
21 changes: 11 additions & 10 deletions packages/accessibility/test/AccessibilityManager.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ import { Renderer } from '@pixi/core';
import { isMobile } from '@pixi/utils';
import { expect } from 'chai';

describe('AccessibilityManager', function ()
describe('AccessibilityManager', () =>
{
it('should exist', function ()
it('should exist', () =>
{
expect(AccessibilityManager).to.be.not.undefined;
});

it('should create new manager', function ()
it('should create new manager', () =>
{
const manager = new AccessibilityManager();
const manager = new AccessibilityManager(undefined);

expect(manager).to.be.instanceof(AccessibilityManager);
manager.destroy();
});

it('should be plugin for renderer', function ()
it('should be plugin for renderer', () =>
{
CanvasRenderer.registerPlugin('accessibility', AccessibilityManager);

Expand All @@ -30,13 +30,13 @@ describe('AccessibilityManager', function ()
renderer.destroy();
});

it('should remove touch hook when destroyed', function ()
it('should remove touch hook when destroyed', () =>
{
const phone = isMobile.phone;

isMobile.phone = true;
const manager = new AccessibilityManager();
const hookDiv = manager._hookDiv;
const manager = new AccessibilityManager(undefined);
const hookDiv = manager['_hookDiv'];

expect(hookDiv).to.be.instanceof(HTMLElement);
expect(document.body.contains(hookDiv)).to.be.true;
Expand All @@ -45,7 +45,7 @@ describe('AccessibilityManager', function ()
isMobile.phone = phone;
});

it('should activate when tab is pressed and deactivate when mouse moved', function ()
it('should activate when tab is pressed and deactivate when mouse moved', () =>
{
const renderer = new Renderer();
const manager = new AccessibilityManager(renderer);
Expand All @@ -56,8 +56,9 @@ describe('AccessibilityManager', function ()
expect(manager.isActive).to.be.false;
});

it('should not crash when scene graph contains DisplayObjects without children', function ()
it('should not crash when scene graph contains DisplayObjects without children', () =>
{
// @ts-expect-error - mock DisplayObject
class CompleteDisplayObject extends DisplayObject
{
calculateBounds() { /* noop */ }
Expand Down
5 changes: 3 additions & 2 deletions packages/accessibility/test/accessibleTarget.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { expect } from 'chai';

import '@pixi/accessibility';

describe('accessibleTarget', function ()
describe('accessibleTarget', () =>
{
it('should have target public properties', function ()
it('should have target public properties', () =>
{
// @ts-expect-error ---
const obj = new DisplayObject();

expect(obj.accessible).to.be.a('boolean');
Expand Down
4 changes: 2 additions & 2 deletions packages/app/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
declare namespace GlobalMixins
{
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface Application
{
resizeTo: Window | HTMLElement;
resize(): void;
queueResize: () => void;
cancelResize: () => void;
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface IApplicationOptions
{
resizeTo?: Window | HTMLElement;
Expand Down
Loading

0 comments on commit 8153970

Please sign in to comment.