From 29804a481c5c36421517736398c4a2472cc2e4eb Mon Sep 17 00:00:00 2001 From: bigopon Date: Sat, 10 Aug 2024 23:56:49 +1000 Subject: [PATCH] chore: cleanup, add more tests --- .gitignore | 3 ++- .oxlintrc.json | 8 ------- karma.conf.js | 57 -------------------------------------------- test/resolve.spec.ts | 21 ++++++++++++++-- tsconfig.dts.json | 13 ---------- tslint.json | 21 ---------------- 6 files changed, 21 insertions(+), 102 deletions(-) delete mode 100644 .oxlintrc.json delete mode 100644 karma.conf.js delete mode 100644 tsconfig.dts.json delete mode 100644 tslint.json diff --git a/.gitignore b/.gitignore index 48bcc07..80e0aa8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ npm-debug.log* .rollupcache dist/doc-temp dist/test -doc/typedoc \ No newline at end of file +doc/typedoc +.npmrc \ No newline at end of file diff --git a/.oxlintrc.json b/.oxlintrc.json deleted file mode 100644 index c0ae291..0000000 --- a/.oxlintrc.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/eslintrc", - "rules": { - "eslint(no-extra-boolean-cast)": "off", - "eslint-plugin-unicorn(no-new-array)": "off", - "no-new-array": "off" - } -} diff --git a/karma.conf.js b/karma.conf.js deleted file mode 100644 index 28118e2..0000000 --- a/karma.conf.js +++ /dev/null @@ -1,57 +0,0 @@ -// Karma configuration -// Generated on Sun Aug 28 2016 19:03:27 GMT-0400 (Eastern Daylight Time) - -module.exports = function(config) { - config.set({ - - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: "", - - // frameworks to use - // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ["jasmine", "requirejs"], - - // list of files / patterns to load in the browser - files: [ - "dist/test/test/main.js", - { pattern: "dist/test/**/*.js", included: false, watched: true }, - //{ pattern: 'dist/test/**/*.html', included: false, watched: true }, - { pattern: "node_modules/**/*.js", included: false, watched: false }, - ], - - // preprocess matching files before serving them to the browser - // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor - preprocessors: { - }, - - // test results reporter to use - // possible values: 'dots', 'progress' - // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ["progress"], - - // web server port - port: 9876, - - // enable / disable colors in the output (reporters and logs) - colors: true, - - // level of logging - // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_INFO, - - // enable / disable watching file and executing tests whenever any file changes - autoWatch: true, - - // start these browsers - // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ["Chrome"], - - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits - singleRun: false, - - // Concurrency level - // how many browser should be started simultaneous - concurrency: Infinity, - }); -}; diff --git a/test/resolve.spec.ts b/test/resolve.spec.ts index 30a3244..e926dbd 100644 --- a/test/resolve.spec.ts +++ b/test/resolve.spec.ts @@ -154,12 +154,11 @@ describe('resolve()', () => { }); }); - describe('combo', function () { + describe('combo', () => { it('works with a combination of usages', () => { class Bar {} class Foo { provider: () => Bar = resolve(Lazy.of(Bar)); - constructor(...args: any[]) {} } const foo1 = container.get(NewInstance.of(Foo)); @@ -171,5 +170,23 @@ describe('resolve()', () => { expect(bar1).toBe(bar2); expect(container.getAll(Bar)).toEqual([bar1]); }); + + it('works with nested resolve', () => { + class Bar {} + class Foo { + provider = resolve(Lazy.of(Bar)); + } + class Baz { + foo = resolve(NewInstance.of(Foo)); + } + + const baz1 = container.get(NewInstance.of(Baz)); + const baz2 = container.get(NewInstance.of(Baz)); + + expect(baz1).not.toBe(baz2); + expect(baz1.foo).not.toBe(baz2.foo); + expect(baz1.foo.provider()).toBe(baz2.foo.provider()); + expect(container.getAll(Bar)).toEqual([baz1.foo.provider()]); + }); }); }); diff --git a/tsconfig.dts.json b/tsconfig.dts.json deleted file mode 100644 index e87d6f0..0000000 --- a/tsconfig.dts.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "./tsconfig.json", - "typeAcquisition": { - "enable": false - }, - "exclude": [ - ".vscode", - "dist", - "doc", - "node_modules", - "test" - ] -} \ No newline at end of file diff --git a/tslint.json b/tslint.json deleted file mode 100644 index 897655b..0000000 --- a/tslint.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "extends": "tslint:latest", - "rules": { - "quotemark": [true, "single"], - "object-literal-sort-keys": false, - "ordered-imports": [false], - "whitespace": [true, "check-branch", "check-decl", "check-operator", "check-module", "check-separator", "check-type"], - "interface-name": [true, "never-prefix"], - "no-shadowed-variable": false, - "no-string-literal": false, - "trailing-comma": [false], - "member-ordering": ["fields-first"], - "array-type": ["array-simple"], - "arrow-parens": false, - "max-classes-per-file": [false], - "prefer-for-of": false, - "prefer-conditional-expression": false, - "no-implicit-dependencies": false, - "variable-name": false - } -}