mirror of https://github.com/apache/nifi.git
[NIFI-12941] - Migrate to Jest from Karma/Jasmine. (#8566)
* [NIFI-12941] - Migrate to Jest from Karma/Jasmine. * Updated license header * Review Feedback * remove jest transforms that were not needed This closes #8566
This commit is contained in:
parent
92830af2e9
commit
039fd66911
|
@ -163,6 +163,21 @@
|
|||
</configuration>
|
||||
</execution>
|
||||
|
||||
<!--
|
||||
Run the unit tests
|
||||
-->
|
||||
<execution>
|
||||
<id>unit-tests</id>
|
||||
<goals>
|
||||
<goal>npm</goal>
|
||||
</goals>
|
||||
<phase>test</phase>
|
||||
<configuration>
|
||||
<arguments>run test</arguments>
|
||||
<workingDirectory>${frontend.working.dir}</workingDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<!--
|
||||
Bundle, minify, and gzip compress all the javascript.
|
||||
-->
|
||||
|
|
|
@ -16,7 +16,7 @@ Run `ng build` to build the project. The build artifacts will be stored in the `
|
|||
|
||||
## Running unit tests
|
||||
|
||||
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
||||
Run `ng test` to execute the unit tests via Jest
|
||||
|
||||
## Running end-to-end tests
|
||||
|
||||
|
|
|
@ -74,15 +74,9 @@
|
|||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"builder": "@angular-builders/jest:run",
|
||||
"options": {
|
||||
"polyfills": ["zone.js", "zone.js/testing"],
|
||||
"tsConfig": "tsconfig.spec.json",
|
||||
"inlineStyleLanguage": "scss",
|
||||
"assets": ["src/favicon.ico", "src/assets"],
|
||||
"styles": ["src/styles.scss"],
|
||||
"scripts": [],
|
||||
"karmaConfig": "karma.conf.js"
|
||||
"configPath": "./jest.config.ts"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
|
|
|
@ -0,0 +1,205 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type { Config } from 'jest';
|
||||
|
||||
const config: Config = {
|
||||
// All imported modules in your tests should be mocked automatically
|
||||
// automock: false,
|
||||
|
||||
// Stop running tests after `n` failures
|
||||
// bail: 0,
|
||||
|
||||
// The directory where Jest should store its cached dependency information
|
||||
// cacheDirectory: "/private/var/folders/c9/pvp6vgmn23nfmvcjbg5jcrrm0000gn/T/jest_dx",
|
||||
|
||||
// Automatically clear mock calls, instances, contexts and results before every test
|
||||
clearMocks: true,
|
||||
|
||||
// Indicates whether the coverage information should be collected while executing the test
|
||||
collectCoverage: true,
|
||||
|
||||
// An array of glob patterns indicating a set of files for which coverage information should be collected
|
||||
// collectCoverageFrom: undefined,
|
||||
|
||||
// The directory where Jest should output its coverage files
|
||||
coverageDirectory: 'coverage',
|
||||
|
||||
// An array of regexp pattern strings used to skip coverage collection
|
||||
// coveragePathIgnorePatterns: [
|
||||
// "/node_modules/"
|
||||
// ],
|
||||
|
||||
// Indicates which provider should be used to instrument code for coverage
|
||||
coverageProvider: 'v8',
|
||||
|
||||
// A list of reporter names that Jest uses when writing coverage reports
|
||||
coverageReporters: ['json', 'html', 'lcov', 'cobertura'],
|
||||
|
||||
// An object that configures minimum threshold enforcement for coverage results
|
||||
// coverageThreshold: undefined,
|
||||
|
||||
// A path to a custom dependency extractor
|
||||
// dependencyExtractor: undefined,
|
||||
|
||||
extensionsToTreatAsEsm: ['.ts'],
|
||||
|
||||
// Make calling deprecated APIs throw helpful error messages
|
||||
// errorOnDeprecated: false,
|
||||
|
||||
// The default configuration for fake timers
|
||||
// fakeTimers: {
|
||||
// "enableGlobally": false
|
||||
// },
|
||||
|
||||
// Force coverage collection from ignored files using an array of glob patterns
|
||||
// forceCoverageMatch: [],
|
||||
|
||||
// A path to a module which exports an async function that is triggered once before all test suites
|
||||
// globalSetup: 'jest-preset-angular/global-setup',
|
||||
|
||||
// A path to a module which exports an async function that is triggered once after all test suites
|
||||
// globalTeardown: undefined,
|
||||
|
||||
// A set of global variables that need to be available in all test environments
|
||||
// globals: {},
|
||||
|
||||
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
|
||||
// maxWorkers: "50%",
|
||||
|
||||
// An array of directory names to be searched recursively up from the requiring module's location
|
||||
// moduleDirectories: [
|
||||
// "node_modules"
|
||||
// ],
|
||||
|
||||
// An array of file extensions your modules use
|
||||
// moduleFileExtensions: [
|
||||
// "js",
|
||||
// "mjs",
|
||||
// "cjs",
|
||||
// "jsx",
|
||||
// "ts",
|
||||
// "tsx",
|
||||
// "json",
|
||||
// "node"
|
||||
// ],
|
||||
|
||||
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
|
||||
// moduleNameMapper: {},
|
||||
|
||||
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
||||
// modulePathIgnorePatterns: [],
|
||||
|
||||
// Activates notifications for test results
|
||||
// notify: false,
|
||||
|
||||
// An enum that specifies notification mode. Requires { notify: true }
|
||||
// notifyMode: "failure-change",
|
||||
|
||||
// A preset that is used as a base for Jest's configuration
|
||||
preset: 'jest-preset-angular/presets/defaults-esm',
|
||||
|
||||
// Run tests from one or more projects
|
||||
// projects: undefined,
|
||||
|
||||
// Use this configuration option to add custom reporters to Jest
|
||||
// reporters: undefined,
|
||||
|
||||
// Automatically reset mock state before every test
|
||||
// resetMocks: false,
|
||||
|
||||
// Reset the module registry before running each individual test
|
||||
// resetModules: false,
|
||||
|
||||
// A path to a custom resolver
|
||||
// resolver: undefined,
|
||||
|
||||
// Automatically restore mock state and implementation before every test
|
||||
// restoreMocks: false,
|
||||
|
||||
// The root directory that Jest should scan for tests and modules within
|
||||
// rootDir: undefined,
|
||||
|
||||
// A list of paths to directories that Jest should use to search for files in
|
||||
// roots: [
|
||||
// "<rootDir>"
|
||||
// ],
|
||||
|
||||
// Allows you to use a custom runner instead of Jest's default test runner
|
||||
// runner: "jest-runner",
|
||||
|
||||
// The paths to modules that run some code to configure or set up the testing environment before each test
|
||||
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
|
||||
|
||||
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
||||
// setupFilesAfterEnv: [],
|
||||
|
||||
// The number of seconds after which a test is considered as slow and reported as such in the results.
|
||||
// slowTestThreshold: 5,
|
||||
|
||||
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
||||
// snapshotSerializers: [],
|
||||
|
||||
// The test environment that will be used for testing
|
||||
testEnvironment: 'jsdom',
|
||||
|
||||
// Options that will be passed to the testEnvironment
|
||||
// testEnvironmentOptions: {},
|
||||
|
||||
// Adds a location field to test results
|
||||
// testLocationInResults: false,
|
||||
|
||||
// The glob patterns Jest uses to detect test files
|
||||
// testMatch: [
|
||||
// "**/__tests__/**/*.[jt]s?(x)",
|
||||
// "**/?(*.)+(spec|test).[tj]s?(x)"
|
||||
// ],
|
||||
|
||||
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
||||
// testPathIgnorePatterns: [
|
||||
// "/node_modules/"
|
||||
// ],
|
||||
|
||||
// The regexp pattern or array of patterns that Jest uses to detect test files
|
||||
// testRegex: [],
|
||||
|
||||
// This option allows the use of a custom results processor
|
||||
// testResultsProcessor: undefined,
|
||||
|
||||
// This option allows use of a custom test runner
|
||||
// testRunner: "jest-circus/runner",
|
||||
|
||||
// A map from regular expressions to paths to transformers
|
||||
transform: {},
|
||||
|
||||
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
||||
transformIgnorePatterns: []
|
||||
|
||||
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
||||
// unmockedModulePathPatterns: undefined,
|
||||
|
||||
// Indicates whether each individual test should be reported during the run
|
||||
// verbose: undefined,
|
||||
|
||||
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
|
||||
// watchPathIgnorePatterns: [],
|
||||
|
||||
// Whether to use watchman for file crawling
|
||||
// watchman: true,
|
||||
};
|
||||
|
||||
export default config;
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Karma configuration file, see link for more information
|
||||
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
||||
|
||||
module.exports = function (config) {
|
||||
config.set({
|
||||
basePath: '',
|
||||
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||
plugins: [
|
||||
require('karma-jasmine'),
|
||||
require('karma-chrome-launcher'),
|
||||
require('karma-jasmine-html-reporter'),
|
||||
require('karma-coverage'),
|
||||
require('@angular-devkit/build-angular/plugins/karma')
|
||||
],
|
||||
client: {
|
||||
jasmine: {
|
||||
// you can add configuration options for Jasmine here
|
||||
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
|
||||
// for example, you can disable the random execution with `random: false`
|
||||
// or set a specific seed with `seed: 4321`
|
||||
},
|
||||
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
||||
},
|
||||
jasmineHtmlReporter: {
|
||||
suppressAll: true // removes the duplicated traces
|
||||
},
|
||||
coverageReporter: {
|
||||
dir: require('path').join(__dirname, './coverage/nifi'),
|
||||
subdir: '.',
|
||||
reporters: [{ type: 'html' }, { type: 'text-summary' }]
|
||||
},
|
||||
reporters: ['progress', 'kjhtml'],
|
||||
browsers: ['ChromeHeadless'],
|
||||
restartOnFileChange: true
|
||||
});
|
||||
};
|
File diff suppressed because it is too large
Load Diff
|
@ -1,81 +1,77 @@
|
|||
{
|
||||
"name": "nifi-web-frontend",
|
||||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"build": "ng build --verbose",
|
||||
"watch": "ng build --watch --configuration development",
|
||||
"test": "ng test --karma-config=karma.conf.js --watch=false",
|
||||
"test:dev": "ng test --karma-config=karma.conf.js --watch=true --browsers=Chrome",
|
||||
"prettier": "prettier --config .prettierrc . --check",
|
||||
"prettier-format": "prettier --config .prettierrc . --write",
|
||||
"ci": "npm ci --ignore-scripts",
|
||||
"lint": "ng lint --eslint-config .eslintrc.json",
|
||||
"lint:fix": "ng lint --eslint-config .eslintrc.json --fix"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^17.1.3",
|
||||
"@angular/cdk": "^17.1.2",
|
||||
"@angular/common": "^17.1.3",
|
||||
"@angular/compiler": "^17.1.3",
|
||||
"@angular/core": "^17.1.3",
|
||||
"@angular/forms": "^17.1.3",
|
||||
"@angular/material": "^17.1.2",
|
||||
"@angular/platform-browser": "^17.1.3",
|
||||
"@angular/platform-browser-dynamic": "^17.1.3",
|
||||
"@angular/router": "^17.1.3",
|
||||
"@ctrl/ngx-codemirror": "^7.0.0",
|
||||
"@fontsource/roboto": "^5.0.12",
|
||||
"@fontsource/roboto-slab": "^5.0.19",
|
||||
"@ngrx/effects": "^17.1.0",
|
||||
"@ngrx/router-store": "^17.1.0",
|
||||
"@ngrx/store": "^17.1.0",
|
||||
"@ngrx/store-devtools": "^17.1.0",
|
||||
"codemirror": "^5.65.16",
|
||||
"d3": "^7.8.5",
|
||||
"font-awesome": "4.7.0",
|
||||
"humanize-duration": "^3.31.0",
|
||||
"ngrx-immer": "^2.1.1",
|
||||
"ngx-skeleton-loader": "^8.1.0",
|
||||
"rxjs": "~7.8.1",
|
||||
"tslib": "^2.6.2",
|
||||
"webfontloader": "^1.6.28",
|
||||
"zone.js": "0.14.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "17.2.0",
|
||||
"@angular-eslint/builder": "17.2.1",
|
||||
"@angular-eslint/eslint-plugin": "17.2.1",
|
||||
"@angular-eslint/eslint-plugin-template": "17.2.1",
|
||||
"@angular-eslint/schematics": "17.2.1",
|
||||
"@angular-eslint/template-parser": "17.2.1",
|
||||
"@angular/cli": "~17.1.3",
|
||||
"@angular/compiler-cli": "^17.1.3",
|
||||
"@types/codemirror": "^5.60.15",
|
||||
"@types/d3": "^7.4.3",
|
||||
"@types/humanize-duration": "^3.27.3",
|
||||
"@types/jasmine": "~4.6.4",
|
||||
"@types/webfontloader": "^1.6.38",
|
||||
"@typescript-eslint/eslint-plugin": "6.21.0",
|
||||
"@typescript-eslint/parser": "6.21.0",
|
||||
"autoprefixer": "^10.4.16",
|
||||
"eslint": "^8.51.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.0.1",
|
||||
"jasmine-core": "~4.6.0",
|
||||
"karma": "~6.4.2",
|
||||
"karma-chrome-launcher": "~3.2.0",
|
||||
"karma-coverage": "~2.2.1",
|
||||
"karma-jasmine": "~5.1.0",
|
||||
"karma-jasmine-html-reporter": "~2.1.0",
|
||||
"postcss": "^8.4.32",
|
||||
"prettier": "3.1.0",
|
||||
"tailwindcss": "^3.3.6",
|
||||
"typescript": "5.3.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=21.0.0"
|
||||
}
|
||||
"name": "nifi-web-frontend",
|
||||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"build": "ng build --verbose",
|
||||
"watch": "ng build --watch --configuration development",
|
||||
"test": "ng test",
|
||||
"test:dev": "ng test --watch=true",
|
||||
"prettier": "prettier --config .prettierrc . --check",
|
||||
"prettier-format": "prettier --config .prettierrc . --write",
|
||||
"ci": "npm ci --ignore-scripts",
|
||||
"lint": "ng lint --eslint-config .eslintrc.json",
|
||||
"lint:fix": "ng lint --eslint-config .eslintrc.json --fix"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^17.1.3",
|
||||
"@angular/cdk": "^17.1.2",
|
||||
"@angular/common": "^17.1.3",
|
||||
"@angular/compiler": "^17.1.3",
|
||||
"@angular/core": "^17.1.3",
|
||||
"@angular/forms": "^17.1.3",
|
||||
"@angular/material": "^17.1.2",
|
||||
"@angular/platform-browser": "^17.1.3",
|
||||
"@angular/platform-browser-dynamic": "^17.1.3",
|
||||
"@angular/router": "^17.1.3",
|
||||
"@ctrl/ngx-codemirror": "^7.0.0",
|
||||
"@fontsource/roboto": "^5.0.12",
|
||||
"@fontsource/roboto-slab": "^5.0.19",
|
||||
"@ngrx/effects": "^17.1.0",
|
||||
"@ngrx/router-store": "^17.1.0",
|
||||
"@ngrx/store": "^17.1.0",
|
||||
"@ngrx/store-devtools": "^17.1.0",
|
||||
"codemirror": "^5.65.16",
|
||||
"d3": "^7.8.5",
|
||||
"font-awesome": "4.7.0",
|
||||
"humanize-duration": "^3.31.0",
|
||||
"ngrx-immer": "^2.1.1",
|
||||
"ngx-skeleton-loader": "^8.1.0",
|
||||
"rxjs": "~7.8.1",
|
||||
"tslib": "^2.6.2",
|
||||
"webfontloader": "^1.6.28",
|
||||
"zone.js": "0.14.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-builders/jest": "^17.0.2",
|
||||
"@angular-devkit/build-angular": "17.2.0",
|
||||
"@angular-eslint/builder": "17.2.1",
|
||||
"@angular-eslint/eslint-plugin": "17.2.1",
|
||||
"@angular-eslint/eslint-plugin-template": "17.2.1",
|
||||
"@angular-eslint/schematics": "17.2.1",
|
||||
"@angular-eslint/template-parser": "17.2.1",
|
||||
"@angular/cli": "~17.1.3",
|
||||
"@angular/compiler-cli": "^17.1.3",
|
||||
"@types/codemirror": "^5.60.15",
|
||||
"@types/d3": "^7.4.3",
|
||||
"@types/humanize-duration": "^3.27.3",
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/webfontloader": "^1.6.38",
|
||||
"@typescript-eslint/eslint-plugin": "6.21.0",
|
||||
"@typescript-eslint/parser": "6.21.0",
|
||||
"autoprefixer": "^10.4.16",
|
||||
"eslint": "^8.51.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.0.1",
|
||||
"jest": "^29.7.0",
|
||||
"postcss": "^8.4.32",
|
||||
"prettier": "3.1.0",
|
||||
"tailwindcss": "^3.3.6",
|
||||
"typescript": "5.3.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=21.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// jsdom testing environment does not provide crypto functionality... provide a dummy implementation in its place.
|
||||
window.crypto.randomUUID = () => {
|
||||
return '7DC4EA44-EA0F-4EAE-8438-274B52620B02';
|
||||
};
|
|
@ -14,3 +14,42 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Bulletins } from './bulletins.component';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { provideMockStore } from '@ngrx/store/testing';
|
||||
import { initialBulletinBoardState } from '../state/bulletin-board/bulletin-board.reducer';
|
||||
import { Component } from '@angular/core';
|
||||
import { BulletinBoard } from '../ui/bulletin-board/bulletin-board.component';
|
||||
|
||||
describe('Bulletins', () => {
|
||||
let component: Bulletins;
|
||||
let fixture: ComponentFixture<Bulletins>;
|
||||
@Component({
|
||||
selector: 'navigation',
|
||||
standalone: true,
|
||||
template: ''
|
||||
})
|
||||
class MockNavigation {}
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [Bulletins],
|
||||
imports: [RouterModule, RouterTestingModule, MockNavigation, BulletinBoard],
|
||||
providers: [
|
||||
provideMockStore({
|
||||
initialState: initialBulletinBoardState
|
||||
})
|
||||
]
|
||||
});
|
||||
fixture = TestBed.createComponent(Bulletins);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -25,6 +25,7 @@ describe('BulletinBoardList', () => {
|
|||
let fixture: ComponentFixture<BulletinBoardList>;
|
||||
|
||||
beforeEach(() => {
|
||||
Element.prototype.scroll = jest.fn();
|
||||
TestBed.configureTestingModule({
|
||||
imports: [BulletinBoardList, NoopAnimationsModule]
|
||||
});
|
||||
|
|
|
@ -1029,7 +1029,7 @@ export class CanvasUtils {
|
|||
});
|
||||
})
|
||||
.on('mouseleave', function () {
|
||||
closeTimer = setTimeout(() => {
|
||||
closeTimer = window.setTimeout(() => {
|
||||
tooltipRef?.destroy();
|
||||
}, 400);
|
||||
});
|
||||
|
|
|
@ -19,29 +19,36 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|||
|
||||
import { Birdseye } from './birdseye.component';
|
||||
import { BirdseyeView } from '../../../../../service/birdseye-view.service';
|
||||
import SpyObj = jasmine.SpyObj;
|
||||
import createSpyObj = jasmine.createSpyObj;
|
||||
|
||||
describe('Birdseye', () => {
|
||||
let component: Birdseye;
|
||||
let fixture: ComponentFixture<Birdseye>;
|
||||
let birdseyeViewSpy: SpyObj<BirdseyeView>;
|
||||
let birdseyeView: BirdseyeView;
|
||||
|
||||
beforeEach(() => {
|
||||
birdseyeViewSpy = createSpyObj('BirdseyeView', ['init', 'refresh']);
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [Birdseye],
|
||||
providers: [{ provide: BirdseyeView, useValue: birdseyeViewSpy }]
|
||||
providers: [
|
||||
{
|
||||
provide: BirdseyeView,
|
||||
useValue: {
|
||||
init: jest.fn(),
|
||||
refresh: jest.fn()
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
fixture = TestBed.createComponent(Birdseye);
|
||||
birdseyeView = TestBed.inject(BirdseyeView);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(birdseyeViewSpy.init).toHaveBeenCalled();
|
||||
expect(birdseyeViewSpy.refresh).toHaveBeenCalled();
|
||||
const initSpy = jest.spyOn(birdseyeView, 'init');
|
||||
const refreshSpy = jest.spyOn(birdseyeView, 'refresh');
|
||||
expect(initSpy).toHaveBeenCalled();
|
||||
expect(refreshSpy).toHaveBeenCalled();
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -22,7 +22,7 @@ import { CanvasState } from '../../../../../state';
|
|||
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
|
||||
import { selectParentProcessGroupId, selectSaving } from '../../../../../state/flow/flow.selectors';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { createPort } from 'src/app/pages/flow-designer/state/flow/flow.actions';
|
||||
import { createPort } from '../../../../../state/flow/flow.actions';
|
||||
import { CreateComponentRequest } from '../../../../../state/flow';
|
||||
import { ComponentType, SelectOption, TextTipInput } from '../../../../../../../state/shared';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
|
|
|
@ -138,7 +138,7 @@ describe('ComboEditor', () => {
|
|||
expect(component.itemLookup.get(formValue)?.value).toEqual(item.value);
|
||||
expect(component.comboEditorForm.get('parameterReference')).toBeNull();
|
||||
|
||||
spyOn(component.ok, 'next');
|
||||
jest.spyOn(component.ok, 'next');
|
||||
component.okClicked();
|
||||
expect(component.ok.next).toHaveBeenCalledWith(item.value);
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ describe('ComboEditor', () => {
|
|||
expect(component.itemLookup.get(formValue)?.value).toEqual(item.descriptor.defaultValue);
|
||||
expect(component.comboEditorForm.get('parameterReference')).toBeNull();
|
||||
|
||||
spyOn(component.ok, 'next');
|
||||
jest.spyOn(component.ok, 'next');
|
||||
component.okClicked();
|
||||
expect(component.ok.next).toHaveBeenCalledWith(item.descriptor.defaultValue);
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ describe('ComboEditor', () => {
|
|||
expect(component.itemLookup.get(formValue)?.value).toEqual(item.value);
|
||||
expect(component.comboEditorForm.get('parameterReference')).toBeNull();
|
||||
|
||||
spyOn(component.ok, 'next');
|
||||
jest.spyOn(component.ok, 'next');
|
||||
component.okClicked();
|
||||
expect(component.ok.next).toHaveBeenCalledWith(item.value);
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ describe('ComboEditor', () => {
|
|||
const parameterReferenceValue = component.comboEditorForm.get('parameterReference')?.value;
|
||||
expect(component.itemLookup.get(parameterReferenceValue)?.value).toEqual(item?.value);
|
||||
|
||||
spyOn(component.ok, 'next');
|
||||
jest.spyOn(component.ok, 'next');
|
||||
component.okClicked();
|
||||
expect(component.ok.next).toHaveBeenCalledWith(item?.value);
|
||||
});
|
||||
|
@ -222,7 +222,7 @@ describe('ComboEditor', () => {
|
|||
const parameterReferenceValue = component.comboEditorForm.get('parameterReference')?.value;
|
||||
expect(component.itemLookup.get(parameterReferenceValue)?.value).toEqual(item?.value);
|
||||
|
||||
spyOn(component.ok, 'next');
|
||||
jest.spyOn(component.ok, 'next');
|
||||
component.okClicked();
|
||||
expect(component.ok.next).toHaveBeenCalledWith('#{' + parameters[0].value + '}');
|
||||
});
|
||||
|
|
|
@ -67,10 +67,10 @@ describe('NfEditor', () => {
|
|||
fixture.detectChanges();
|
||||
|
||||
expect(component.nfEditorForm.get('value')?.value).toEqual(value);
|
||||
expect(component.nfEditorForm.get('value')?.disabled).toBeFalse();
|
||||
expect(component.nfEditorForm.get('setEmptyString')?.value).toBeFalse();
|
||||
expect(component.nfEditorForm.get('value')?.disabled).toBeFalsy();
|
||||
expect(component.nfEditorForm.get('setEmptyString')?.value).toBeFalsy();
|
||||
|
||||
spyOn(component.ok, 'next');
|
||||
jest.spyOn(component.ok, 'next');
|
||||
component.okClicked();
|
||||
expect(component.ok.next).toHaveBeenCalledWith(value);
|
||||
});
|
||||
|
@ -107,7 +107,7 @@ describe('NfEditor', () => {
|
|||
expect(component.nfEditorForm.get('value')?.disabled).toBeTruthy();
|
||||
expect(component.nfEditorForm.get('setEmptyString')?.value).toBeTruthy();
|
||||
|
||||
spyOn(component.ok, 'next');
|
||||
jest.spyOn(component.ok, 'next');
|
||||
component.okClicked();
|
||||
expect(component.ok.next).toHaveBeenCalledWith(value);
|
||||
});
|
||||
|
|
|
@ -168,7 +168,7 @@ export class PropertyTable implements AfterViewInit, ControlValueAccessor {
|
|||
// scroll into view
|
||||
valueTrigger.elementRef.nativeElement.scrollIntoView({ block: 'center', behavior: 'instant' });
|
||||
|
||||
setTimeout(function () {
|
||||
window.setTimeout(function () {
|
||||
// trigger a click to start editing the new item
|
||||
valueTrigger.elementRef.nativeElement.click();
|
||||
}, 0);
|
||||
|
|
|
@ -46,7 +46,7 @@ describe('YesNoDialog', () => {
|
|||
});
|
||||
|
||||
it('should emit when yes clicked', () => {
|
||||
spyOn(component.yes, 'next');
|
||||
jest.spyOn(component.yes, 'next');
|
||||
component.yesClicked();
|
||||
expect(component.yes.next).toHaveBeenCalled();
|
||||
});
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/spec",
|
||||
"types": ["jasmine"]
|
||||
"types": ["jest"],
|
||||
"module": "ES2022",
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue