Skip to content

Commit

Permalink
test: move test folder to src (#1661)
Browse files Browse the repository at this point in the history
  • Loading branch information
notaphplover authored Nov 30, 2024
1 parent 66ebe9a commit 756d338
Show file tree
Hide file tree
Showing 62 changed files with 197 additions and 211 deletions.
2 changes: 0 additions & 2 deletions .auditignore

This file was deleted.

3 changes: 1 addition & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.auditignore
.github
.gitignore
.nyc_output
Expand All @@ -14,6 +13,7 @@ ISSUE_TEMPLATE.md
lib/esm/**/*.d.ts.map
!lib/esm/index.d.ts
!lib/esm/index.d.ts.map
lib/*/test/**
mocha.opts
prettier.config.mjs
PULL_REQUEST_TEMPLATE.md
Expand All @@ -22,7 +22,6 @@ rollup.config.mjs
scripts
src
temp
test
tsconfig.json
tsconfig.base.cjs.json
tsconfig.base.esm.json
Expand Down
3 changes: 0 additions & 3 deletions mocha.opts

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
"lint": "eslint ./src",
"prebuild": "npm run build:clean",
"prepublish": "npm run build",
"test": "nyc --reporter=lcov --require ts-node/register mocha ./test/*.test.ts test/**/*.test.ts --reporter spec --retries 3 --require 'node_modules/reflect-metadata/Reflect.js' --exit"
"test": "nyc --reporter=lcov --require ts-node/register mocha src/test/*.test.ts src/test/**/*.test.ts --reporter spec --require 'node_modules/reflect-metadata/Reflect.js' --exit",
"test:cjs": "nyc --reporter=lcov mocha lib/cjs/test/*.test.js lib/cjs/test/**/*.test.js --reporter spec --require 'node_modules/reflect-metadata/Reflect.js'"
},
"sideEffects": false,
"version": "6.1.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {
DecoratorTarget,
tagParameter,
tagProperty,
} from '../../src/annotation/decorator_utils';
import * as ERROR_MSGS from '../../src/constants/error_msgs';
import { Container, inject, injectable, interfaces } from '../../src/index';
import { Metadata } from '../../src/planning/metadata';
} from '../../annotation/decorator_utils';
import * as ERROR_MSGS from '../../constants/error_msgs';
import { Container, inject, injectable, interfaces } from '../../index';
import { Metadata } from '../../planning/metadata';

describe('createTaggedDecorator', () => {
let sandbox: sinon.SinonSandbox;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ declare function __param(
import { LazyServiceIdentifier } from '@inversifyjs/common';
import { expect } from 'chai';

import { decorate } from '../../src/annotation/decorator_utils';
import { inject } from '../../src/annotation/inject';
import { multiInject } from '../../src/annotation/multi_inject';
import * as ERROR_MSGS from '../../src/constants/error_msgs';
import * as METADATA_KEY from '../../src/constants/metadata_keys';
import type { interfaces } from '../../src/interfaces/interfaces';
import { decorate } from '../../annotation/decorator_utils';
import { inject } from '../../annotation/inject';
import { multiInject } from '../../annotation/multi_inject';
import * as ERROR_MSGS from '../../constants/error_msgs';
import * as METADATA_KEY from '../../constants/metadata_keys';
import type { interfaces } from '../../interfaces/interfaces';

class Katana {}
class Shuriken {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect } from 'chai';

import * as ERRORS_MSGS from '../../src/constants/error_msgs';
import * as METADATA_KEY from '../../src/constants/metadata_keys';
import { decorate, injectable } from '../../src/index';
import * as ERRORS_MSGS from '../../constants/error_msgs';
import * as METADATA_KEY from '../../constants/metadata_keys';
import { decorate, injectable } from '../../index';

describe('@injectable', () => {
it('Should generate metadata if declared injections', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ declare function __param(

import { expect } from 'chai';

import { decorate } from '../../src/annotation/decorator_utils';
import { multiInject } from '../../src/annotation/multi_inject';
import * as ERROR_MSGS from '../../src/constants/error_msgs';
import * as METADATA_KEY from '../../src/constants/metadata_keys';
import type { interfaces } from '../../src/interfaces/interfaces';
import { decorate } from '../../annotation/decorator_utils';
import { multiInject } from '../../annotation/multi_inject';
import * as ERROR_MSGS from '../../constants/error_msgs';
import * as METADATA_KEY from '../../constants/metadata_keys';
import type { interfaces } from '../../interfaces/interfaces';

type Weapon = object;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ declare function __param(

import { expect } from 'chai';

import { decorate } from '../../src/annotation/decorator_utils';
import { named } from '../../src/annotation/named';
import * as ERROR_MSGS from '../../src/constants/error_msgs';
import * as METADATA_KEY from '../../src/constants/metadata_keys';
import type { interfaces } from '../../src/interfaces/interfaces';
import { decorate } from '../../annotation/decorator_utils';
import { named } from '../../annotation/named';
import * as ERROR_MSGS from '../../constants/error_msgs';
import * as METADATA_KEY from '../../constants/metadata_keys';
import type { interfaces } from '../../interfaces/interfaces';

type Weapon = unknown;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';

import { Container, inject, injectable, optional } from '../../src/index';
import { Container, inject, injectable, optional } from '../../index';

describe('@optional', () => {
it('Should allow to flag dependencies as optional', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { expect } from 'chai';

import { postConstruct } from '../../src/annotation/post_construct';
import * as ERRORS_MSGS from '../../src/constants/error_msgs';
import * as METADATA_KEY from '../../src/constants/metadata_keys';
import { decorate } from '../../src/index';
import { Metadata } from '../../src/planning/metadata';
import { postConstruct } from '../../annotation/post_construct';
import * as ERRORS_MSGS from '../../constants/error_msgs';
import * as METADATA_KEY from '../../constants/metadata_keys';
import { decorate } from '../../index';
import { Metadata } from '../../planning/metadata';

describe('@postConstruct', () => {
it('Should generate metadata for the decorated method', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ declare function __param(

import { expect } from 'chai';

import { decorate } from '../../src/annotation/decorator_utils';
import { tagged } from '../../src/annotation/tagged';
import * as ERRORS_MSGS from '../../src/constants/error_msgs';
import * as METADATA_KEY from '../../src/constants/metadata_keys';
import type { interfaces } from '../../src/interfaces/interfaces';
import { decorate } from '../../annotation/decorator_utils';
import { tagged } from '../../annotation/tagged';
import * as ERRORS_MSGS from '../../constants/error_msgs';
import * as METADATA_KEY from '../../constants/metadata_keys';
import type { interfaces } from '../../interfaces/interfaces';

type Weapon = unknown;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { expect } from 'chai';

import { decorate } from '../../src/annotation/decorator_utils';
import { injectable } from '../../src/annotation/injectable';
import { targetName } from '../../src/annotation/target_name';
import * as METADATA_KEY from '../../src/constants/metadata_keys';
import type { interfaces } from '../../src/index';
import { Metadata } from '../../src/planning/metadata';
import { decorate } from '../../annotation/decorator_utils';
import { injectable } from '../../annotation/injectable';
import { targetName } from '../../annotation/target_name';
import * as METADATA_KEY from '../../constants/metadata_keys';
import type { interfaces } from '../../index';
import { Metadata } from '../../planning/metadata';
import * as Stubs from '../utils/stubs';

describe('@targetName', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';

import { Binding } from '../../src/bindings/binding';
import { BindingScopeEnum } from '../../src/constants/literal_types';
import { Binding } from '../../bindings/binding';
import { BindingScopeEnum } from '../../constants/literal_types';
import * as Stubs from '../utils/stubs';

describe('Binding', () => {
Expand Down
14 changes: 7 additions & 7 deletions test/bugs/bugs.test.ts → src/test/bugs/bugs.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';

import * as ERROR_MSGS from '../../src/constants/error_msgs';
import * as METADATA_KEY from '../../src/constants/metadata_keys';
import * as ERROR_MSGS from '../../constants/error_msgs';
import * as METADATA_KEY from '../../constants/metadata_keys';
import {
Container,
decorate,
Expand All @@ -13,14 +13,14 @@ import {
tagged,
targetName,
unmanaged,
} from '../../src/index';
import { Metadata } from '../../src/planning/metadata';
import { MetadataReader } from '../../src/planning/metadata_reader';
import { getDependencies } from '../../src/planning/reflection_utils';
} from '../../index';
import { Metadata } from '../../planning/metadata';
import { MetadataReader } from '../../planning/metadata_reader';
import { getDependencies } from '../../planning/reflection_utils';
import {
getFunctionName,
getServiceIdentifierAsString,
} from '../../src/utils/serialization';
} from '../../utils/serialization';

describe('Bugs', () => {
it('Should throw when args length of base and derived class not match', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { expect } from 'chai';

import {
Container,
inject,
injectable,
named,
optional,
} from '../../src/index';
import { Container, inject, injectable, named, optional } from '../../index';

describe('Issue 1190', () => {
it('should inject a katana as default weapon to ninja', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import * as sinon from 'sinon';

import { Container, injectable, interfaces } from '../../src/index';
import { Container, injectable, interfaces } from '../../index';

describe('Issue 1297', () => {
it('should call onActivation once if the service is a constant value binding', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, it } from 'mocha';
import sinon from 'sinon';

import { Container, injectable, preDestroy } from '../../src/index';
import { Container, injectable, preDestroy } from '../../index';

describe('Issue 1416', () => {
it('should allow providing default values on optional bindings', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';

import { Container, inject, injectable, multiInject } from '../../src/index';
import { Container, inject, injectable, multiInject } from '../../index';

describe('Issue 1515', () => {
it('should properly throw on circular dependency', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';

import { Container } from '../../src/index';
import { Container } from '../../index';

describe('Issue 1518', () => {
it('should not throw on deactivating undefined singleton values', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import { Container, inject, injectable } from '../../src/index';
import { Container, inject, injectable } from '../../index';

describe('Issue 1564', () => {
it('should not throw on getting async services bound using "toService"', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';

import * as ERROR_MSGS from '../../src/constants/error_msgs';
import { Container, inject, injectable } from '../../src/index';
import * as ERROR_MSGS from '../../constants/error_msgs';
import { Container, inject, injectable } from '../../index';

describe('Issue 543', () => {
it('Should throw correct circular dependency path', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ERROR_MSGS from '../../src/constants/error_msgs';
import { Container, inject, injectable, interfaces } from '../../src/index';
import * as ERROR_MSGS from '../../constants/error_msgs';
import { Container, inject, injectable, interfaces } from '../../index';

describe('Issue 549', () => {
it('Should throw if circular dependencies found with dynamics', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';

import { Container, injectable, interfaces } from '../../src/index';
import { Container, injectable, interfaces } from '../../index';

describe('Issue 633', () => {
it('Should expose metadata through context', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';

import { BindingScopeEnum, Container, injectable } from '../../src/index';
import { BindingScopeEnum, Container, injectable } from '../../index';

describe('Issue 706', () => {
it('Should expose BindingScopeEnum as part of the public API', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';

import { Container, inject, injectable, optional } from '../../src/index';
import { Container, inject, injectable, optional } from '../../index';

describe('Issue 928', () => {
it('should inject the right instances', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';

import * as ERROR_MSGS from '../../src/constants/error_msgs';
import * as ERROR_MSGS from '../../constants/error_msgs';

describe('ERROR_MSGS', () => {
it('Should be able to customize POST_CONSTRUCT_ERROR', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { assert, expect } from 'chai';
import * as sinon from 'sinon';

import { inject } from '../../src/annotation/inject';
import { injectable } from '../../src/annotation/injectable';
import { postConstruct } from '../../src/annotation/post_construct';
import * as ERROR_MSGS from '../../src/constants/error_msgs';
import { BindingScopeEnum } from '../../src/constants/literal_types';
import { Container } from '../../src/container/container';
import { ContainerModule } from '../../src/container/container_module';
import { ModuleActivationStore } from '../../src/container/module_activation_store';
import type { interfaces } from '../../src/interfaces/interfaces';
import { getBindingDictionary } from '../../src/planning/planner';
import { getServiceIdentifierAsString } from '../../src/utils/serialization';
import { inject } from '../../annotation/inject';
import { injectable } from '../../annotation/injectable';
import { postConstruct } from '../../annotation/post_construct';
import * as ERROR_MSGS from '../../constants/error_msgs';
import { BindingScopeEnum } from '../../constants/literal_types';
import { Container } from '../../container/container';
import { ContainerModule } from '../../container/container_module';
import { ModuleActivationStore } from '../../container/module_activation_store';
import type { interfaces } from '../../interfaces/interfaces';
import { getBindingDictionary } from '../../planning/planner';
import { getServiceIdentifierAsString } from '../../utils/serialization';

type Dictionary = Map<
interfaces.ServiceIdentifier,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { expect } from 'chai';
import * as sinon from 'sinon';

import { NOT_REGISTERED } from '../../src/constants/error_msgs';
import { Container } from '../../src/container/container';
import { NOT_REGISTERED } from '../../constants/error_msgs';
import { Container } from '../../container/container';
import {
AsyncContainerModule,
ContainerModule,
} from '../../src/container/container_module';
import type { interfaces } from '../../src/interfaces/interfaces';
} from '../../container/container_module';
import type { interfaces } from '../../interfaces/interfaces';

describe('ContainerModule', () => {
it('Should be able to set the registry of a container module', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { expect } from 'chai';

import { Binding } from '../../src/bindings/binding';
import * as ERROR_MSGS from '../../src/constants/error_msgs';
import { BindingScopeEnum } from '../../src/constants/literal_types';
import { Lookup } from '../../src/container/lookup';
import type { interfaces } from '../../src/interfaces/interfaces';
import { Binding } from '../../bindings/binding';
import * as ERROR_MSGS from '../../constants/error_msgs';
import { BindingScopeEnum } from '../../constants/literal_types';
import { Lookup } from '../../container/lookup';
import type { interfaces } from '../../interfaces/interfaces';

class ClonableValue<T> implements interfaces.Clonable<ClonableValue<T>> {
public readonly val: T;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';

import { ModuleActivationStore } from '../../src/container/module_activation_store';
import type { interfaces } from '../../src/index';
import { ModuleActivationStore } from '../../container/module_activation_store';
import type { interfaces } from '../../index';

describe('ModuleActivationStore', () => {
it('should remove handlers added by the module', () => {
Expand Down
Loading

0 comments on commit 756d338

Please sign in to comment.