diff --git a/.gitignore b/.gitignore index 8544c27..4179018 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,5 @@ dist/ dist-test/ node_modules/ npm-debug.log -.vscode/ lib/ bin/ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..e5dc691 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,20 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Jest All", + "program": "${workspaceFolder}/node_modules/.bin/jest", + "args": [ + "--runInBand" + ], + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen", + "disableOptimisticBPs": true, + "windows": { + "program": "${workspaceFolder}/node_modules/jest/bin/jest", + } + } + ] +} diff --git a/tsconfig.bin.json b/bin.tsconfig.json similarity index 83% rename from tsconfig.bin.json rename to bin.tsconfig.json index bb6e0cd..8af8ab6 100644 --- a/tsconfig.bin.json +++ b/bin.tsconfig.json @@ -6,5 +6,5 @@ "outFile": "bin/tsdb-kit.js" }, "include": [ "src/**/*.ts" ], - "exclude": [ "src/index.ts" ] + "exclude": [ "src/index.ts" ] } diff --git a/jest.config.js b/jest.config.js index 4f0f1e2..0c8cb56 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,21 +1,11 @@ module.exports = { - "verbose": true, - "globals": { - "ts-jest": { - "useBabelrc": true, - "tsConfigFile": "tsconfig.jest.json" - } - }, - "transform": { - "\\.ts": "ts-jest" - }, - "testRegex": "(\\.|/)([jt]est)\\.[jt]s$", - "moduleFileExtensions": [ - "ts", - "js", - "json" - ], - "setupFiles": [ + verbose: true, + preset: 'ts-jest', + testEnvironment: 'node', + setupFiles: [ "/spec/setup_tests.ts" - ] + ], + // TODO: folder structure defualt for jest, so + // no preference about the testRegex + testRegex: "(\\.|/)([jt]est)\\.[jt]s$" }; diff --git a/tsconfig.lib.json b/lib.tsconfig.json similarity index 100% rename from tsconfig.lib.json rename to lib.tsconfig.json diff --git a/package.json b/package.json index a3910cc..8c58ff1 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,10 @@ "description": "", "scripts": { "build": "yarn build:lib && yarn build:bin", - "build:lib": "tsc --p tsconfig.lib.json", - "build:bin": "tsc --p tsconfig.bin.json", + "build:lib": "tsc --p lib.tsconfig.json", + "build:bin": "tsc --p bin.tsconfig.json", "dev": "tsc -w", - "test": "jest --config jest.config.js" + "test": "jest" }, "repository": { "type": "git", diff --git a/spec/elasticsearch.jest.ts b/spec/elasticsearch.jest.ts index cb797da..28349d0 100644 --- a/spec/elasticsearch.jest.ts +++ b/spec/elasticsearch.jest.ts @@ -30,7 +30,7 @@ describe('simple query', function(){ { "query_string": { "analyze_wildcard": true, - "query": "beat.hostname:opt-project.ru AND !system.network.name:\"IBM USB Remote NDIS Network Device\"" + "query": "beat.hostname:example.com AND !system.network.name:\"IBM USB Remote NDIS Network Device\"" } } ] @@ -100,7 +100,7 @@ describe('simple query', function(){ "type": "derivative" } ], - "query": "beat.hostname:opt-project.ru AND !system.network.name:\"IBM USB Remote NDIS Network Device\"", + "query": "beat.hostname:example.com AND !system.network.name:\"IBM USB Remote NDIS Network Device\"", "refId": "A", "target": "carbon.agents.0b0226864dc8-a.cpuUsage", "timeField": "@timestamp" @@ -129,7 +129,7 @@ describe('simple query', function(){ { "query_string": { "analyze_wildcard": true, - "query": "beat.hostname:opt-project.ru AND !system.network.name:\"IBM USB Remote NDIS Network Device\"" + "query": "beat.hostname:example.com AND !system.network.name:\"IBM USB Remote NDIS Network Device\"" } } ] @@ -167,6 +167,9 @@ describe('simple query', function(){ it('check correct time processing', function() { let expectedQuery = { + headers: { + 'Content-Type': 'application/json' + }, url: datasourse.url, method: 'POST', schema: { @@ -179,7 +182,9 @@ describe('simple query', function(){ let limit = 222; let offset = 333; - expect(elasticMetric.getQuery(from, to, limit, offset)).toEqual(expectedQuery); + let result = elasticMetric.getQuery(from, to, limit, offset); + + expect(result).toEqual(expectedQuery); }); diff --git a/tsconfig.jest.json b/tsconfig.jest.json deleted file mode 100644 index 1c66acf..0000000 --- a/tsconfig.jest.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./tsconfig" -}