mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
feat(remission-return-receipt-list): rewrite unit tests with Angular Testing Utilities
- Replace Spectator with Angular's official TestBed and ComponentFixture - Implement isolated test approach with proper AAA pattern - Fix TypeScript errors related to Return interface type mismatches - Add comprehensive edge case testing and error handling - Create proper mock components for child dependencies - Ensure all 47 tests pass with improved maintainability
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||||
import { MockComponent, MockDirective, MockProvider } from 'ng-mocks';
|
import { MockComponent, MockDirective } from 'ng-mocks';
|
||||||
import { of } from 'rxjs';
|
|
||||||
import { RemissionReturnReceiptDetailsItemComponent } from './remission-return-receipt-details-item.component';
|
import { RemissionReturnReceiptDetailsItemComponent } from './remission-return-receipt-details-item.component';
|
||||||
import { ProductFormatComponent } from '@isa/shared/product-foramt';
|
import { ProductFormatComponent } from '@isa/shared/product-foramt';
|
||||||
import { ProductImageDirective } from '@isa/shared/product-image';
|
import { ProductImageDirective } from '@isa/shared/product-image';
|
||||||
@@ -13,10 +12,6 @@ import {
|
|||||||
RemissionReturnReceiptService,
|
RemissionReturnReceiptService,
|
||||||
} from '@isa/remission/data-access';
|
} from '@isa/remission/data-access';
|
||||||
import { IconButtonComponent } from '@isa/ui/buttons';
|
import { IconButtonComponent } from '@isa/ui/buttons';
|
||||||
import {
|
|
||||||
BulletListComponent,
|
|
||||||
BulletListItemComponent,
|
|
||||||
} from '@isa/ui/bullet-list';
|
|
||||||
|
|
||||||
describe('RemissionReturnReceiptDetailsItemComponent', () => {
|
describe('RemissionReturnReceiptDetailsItemComponent', () => {
|
||||||
let component: RemissionReturnReceiptDetailsItemComponent;
|
let component: RemissionReturnReceiptDetailsItemComponent;
|
||||||
@@ -90,6 +85,10 @@ describe('RemissionReturnReceiptDetailsItemComponent', () => {
|
|||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
mockRemissionReturnReceiptService.removeReturnItemFromReturnReceipt.mockClear();
|
||||||
|
});
|
||||||
|
|
||||||
describe('Component Setup', () => {
|
describe('Component Setup', () => {
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
fixture.componentRef.setInput('item', mockReceiptItem);
|
fixture.componentRef.setInput('item', mockReceiptItem);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
329
nx.json
329
nx.json
@@ -1,165 +1,164 @@
|
|||||||
{
|
{
|
||||||
"$schema": "./node_modules/nx/schemas/nx-schema.json",
|
"$schema": "./node_modules/nx/schemas/nx-schema.json",
|
||||||
"cli": {
|
"cli": {
|
||||||
"packageManager": "npm"
|
"packageManager": "npm"
|
||||||
},
|
},
|
||||||
"targetDefaults": {
|
"targetDefaults": {
|
||||||
"build": {
|
"build": {
|
||||||
"cache": true,
|
"cache": true,
|
||||||
"dependsOn": ["^build"],
|
"dependsOn": ["^build"],
|
||||||
"inputs": ["production", "^production"]
|
"inputs": ["production", "^production"]
|
||||||
},
|
},
|
||||||
"test": {
|
"test": {
|
||||||
"cache": true,
|
"cache": true,
|
||||||
"inputs": ["default", "^production", "{workspaceRoot}/karma.conf.js"]
|
"inputs": ["default", "^production", "{workspaceRoot}/karma.conf.js"]
|
||||||
},
|
},
|
||||||
"@nx/eslint:lint": {
|
"@nx/eslint:lint": {
|
||||||
"cache": true,
|
"cache": true,
|
||||||
"inputs": [
|
"inputs": [
|
||||||
"default",
|
"default",
|
||||||
"{workspaceRoot}/.eslintrc.json",
|
"{workspaceRoot}/.eslintrc.json",
|
||||||
"{workspaceRoot}/.eslintignore",
|
"{workspaceRoot}/.eslintignore",
|
||||||
"{workspaceRoot}/eslint.config.js"
|
"{workspaceRoot}/eslint.config.js"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"@nx/jest:jest": {
|
"@nx/jest:jest": {
|
||||||
"cache": true,
|
"cache": true,
|
||||||
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
|
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
|
||||||
"options": {
|
"options": {
|
||||||
"passWithNoTests": true
|
"passWithNoTests": true
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"ci": {
|
"ci": {
|
||||||
"ci": true,
|
"ci": true,
|
||||||
"codeCoverage": true
|
"codeCoverage": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@nx/js:tsc": {
|
"@nx/js:tsc": {
|
||||||
"cache": true,
|
"cache": true,
|
||||||
"dependsOn": ["^build"],
|
"dependsOn": ["^build"],
|
||||||
"inputs": ["production", "^production"]
|
"inputs": ["production", "^production"]
|
||||||
},
|
},
|
||||||
"@angular-devkit/build-angular:application": {
|
"@angular-devkit/build-angular:application": {
|
||||||
"cache": true,
|
"cache": true,
|
||||||
"dependsOn": ["^build"],
|
"dependsOn": ["^build"],
|
||||||
"inputs": ["production", "^production"]
|
"inputs": ["production", "^production"]
|
||||||
},
|
},
|
||||||
"build-storybook": {
|
"build-storybook": {
|
||||||
"cache": true
|
"cache": true
|
||||||
},
|
},
|
||||||
"@nx/angular:ng-packagr-lite": {
|
"@nx/angular:ng-packagr-lite": {
|
||||||
"cache": true,
|
"cache": true,
|
||||||
"dependsOn": ["^build"],
|
"dependsOn": ["^build"],
|
||||||
"inputs": ["production", "^production"]
|
"inputs": ["production", "^production"]
|
||||||
},
|
},
|
||||||
"@nx/vite:test": {
|
"@nx/vite:test": {
|
||||||
"cache": true,
|
"cache": true,
|
||||||
"inputs": ["default", "^production"]
|
"inputs": ["default", "^production"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"defaultBase": "develop",
|
"defaultBase": "develop",
|
||||||
"namedInputs": {
|
"namedInputs": {
|
||||||
"sharedGlobals": [],
|
"sharedGlobals": [],
|
||||||
"default": ["{projectRoot}/**/*", "sharedGlobals"],
|
"default": ["{projectRoot}/**/*", "sharedGlobals"],
|
||||||
"production": [
|
"production": [
|
||||||
"default",
|
"default",
|
||||||
"!{projectRoot}/tsconfig.spec.json",
|
"!{projectRoot}/tsconfig.spec.json",
|
||||||
"!{projectRoot}/**/*.spec.[jt]s",
|
"!{projectRoot}/**/*.spec.[jt]s",
|
||||||
"!{projectRoot}/.eslintrc.json",
|
"!{projectRoot}/.eslintrc.json",
|
||||||
"!{projectRoot}/eslint.config.js",
|
"!{projectRoot}/eslint.config.js",
|
||||||
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
|
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
|
||||||
"!{projectRoot}/jest.config.[jt]s",
|
"!{projectRoot}/jest.config.[jt]s",
|
||||||
"!{projectRoot}/src/test-setup.[jt]s",
|
"!{projectRoot}/src/test-setup.[jt]s",
|
||||||
"!{projectRoot}/test-setup.[jt]s",
|
"!{projectRoot}/test-setup.[jt]s",
|
||||||
"!{projectRoot}/**/*.stories.@(js|jsx|ts|tsx|mdx)",
|
"!{projectRoot}/**/*.stories.@(js|jsx|ts|tsx|mdx)",
|
||||||
"!{projectRoot}/.storybook/**/*",
|
"!{projectRoot}/.storybook/**/*",
|
||||||
"!{projectRoot}/tsconfig.storybook.json"
|
"!{projectRoot}/tsconfig.storybook.json"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"generators": {
|
"generators": {
|
||||||
"@nx/angular:library": {
|
"@nx/angular:library": {
|
||||||
"linter": "eslint",
|
"linter": "eslint",
|
||||||
"unitTestRunner": "none"
|
"unitTestRunner": "none"
|
||||||
},
|
},
|
||||||
"@nx/angular:component": {
|
"@nx/angular:component": {
|
||||||
"style": "css",
|
"style": "css",
|
||||||
"type": "component"
|
"type": "component"
|
||||||
},
|
},
|
||||||
"@nx/angular:application": {
|
"@nx/angular:application": {
|
||||||
"e2eTestRunner": "none",
|
"e2eTestRunner": "none",
|
||||||
"linter": "eslint",
|
"linter": "eslint",
|
||||||
"style": "css",
|
"style": "css",
|
||||||
"unitTestRunner": "jest"
|
"unitTestRunner": "jest"
|
||||||
},
|
},
|
||||||
"@schematics/angular:component": {
|
"@schematics/angular:component": {
|
||||||
"type": "component"
|
"type": "component"
|
||||||
},
|
},
|
||||||
"@nx/angular:directive": {
|
"@nx/angular:directive": {
|
||||||
"type": "directive"
|
"type": "directive"
|
||||||
},
|
},
|
||||||
"@schematics/angular:directive": {
|
"@schematics/angular:directive": {
|
||||||
"type": "directive"
|
"type": "directive"
|
||||||
},
|
},
|
||||||
"@nx/angular:service": {
|
"@nx/angular:service": {
|
||||||
"type": "service"
|
"type": "service"
|
||||||
},
|
},
|
||||||
"@schematics/angular:service": {
|
"@schematics/angular:service": {
|
||||||
"type": "service"
|
"type": "service"
|
||||||
},
|
},
|
||||||
"@nx/angular:scam": {
|
"@nx/angular:scam": {
|
||||||
"type": "component"
|
"type": "component"
|
||||||
},
|
},
|
||||||
"@nx/angular:scam-directive": {
|
"@nx/angular:scam-directive": {
|
||||||
"type": "directive"
|
"type": "directive"
|
||||||
},
|
},
|
||||||
"@nx/angular:guard": {
|
"@nx/angular:guard": {
|
||||||
"typeSeparator": "."
|
"typeSeparator": "."
|
||||||
},
|
},
|
||||||
"@schematics/angular:guard": {
|
"@schematics/angular:guard": {
|
||||||
"typeSeparator": "."
|
"typeSeparator": "."
|
||||||
},
|
},
|
||||||
"@nx/angular:interceptor": {
|
"@nx/angular:interceptor": {
|
||||||
"typeSeparator": "."
|
"typeSeparator": "."
|
||||||
},
|
},
|
||||||
"@schematics/angular:interceptor": {
|
"@schematics/angular:interceptor": {
|
||||||
"typeSeparator": "."
|
"typeSeparator": "."
|
||||||
},
|
},
|
||||||
"@nx/angular:module": {
|
"@nx/angular:module": {
|
||||||
"typeSeparator": "."
|
"typeSeparator": "."
|
||||||
},
|
},
|
||||||
"@schematics/angular:module": {
|
"@schematics/angular:module": {
|
||||||
"typeSeparator": "."
|
"typeSeparator": "."
|
||||||
},
|
},
|
||||||
"@nx/angular:pipe": {
|
"@nx/angular:pipe": {
|
||||||
"typeSeparator": "."
|
"typeSeparator": "."
|
||||||
},
|
},
|
||||||
"@schematics/angular:pipe": {
|
"@schematics/angular:pipe": {
|
||||||
"typeSeparator": "."
|
"typeSeparator": "."
|
||||||
},
|
},
|
||||||
"@nx/angular:resolver": {
|
"@nx/angular:resolver": {
|
||||||
"typeSeparator": "."
|
"typeSeparator": "."
|
||||||
},
|
},
|
||||||
"@schematics/angular:resolver": {
|
"@schematics/angular:resolver": {
|
||||||
"typeSeparator": "."
|
"typeSeparator": "."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
{
|
{
|
||||||
"plugin": "@nx/eslint/plugin",
|
"plugin": "@nx/eslint/plugin",
|
||||||
"options": {
|
"options": {
|
||||||
"targetName": "eslint:lint"
|
"targetName": "eslint:lint"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"plugin": "@nx/storybook/plugin",
|
"plugin": "@nx/storybook/plugin",
|
||||||
"options": {
|
"options": {
|
||||||
"serveStorybookTargetName": "storybook",
|
"serveStorybookTargetName": "storybook",
|
||||||
"buildStorybookTargetName": "build-storybook",
|
"buildStorybookTargetName": "build-storybook",
|
||||||
"testStorybookTargetName": "test-storybook",
|
"testStorybookTargetName": "test-storybook",
|
||||||
"staticStorybookTargetName": "static-storybook"
|
"staticStorybookTargetName": "static-storybook"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"nxCloudId": "686ee1ec0f8935752d36306a"
|
}
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user