--- /dev/null
+import { QueryList } from "@angular/core";
+import { waitForAsync } from "@angular/core/testing";
+import { AuthService } from "@eg/core/auth.service";
+import { FormatService } from "@eg/core/format.service";
+import { IdlService } from "@eg/core/idl.service";
+import { OrgService } from "@eg/core/org.service";
+import { StoreService } from "@eg/core/store.service";
+import { ComboboxComponent } from "@eg/share/combobox/combobox.component";
+import { ToastService } from "@eg/share/toast/toast.service";
+import { FileExportService } from "@eg/share/util/file-export.service";
+import { CopyAttrsComponent } from "./copy-attrs.component";
+import { VolCopyService } from "./volcopy.service";
+
+describe('CopyAttrsComponent', () => {
+ let component: CopyAttrsComponent;
+ const idlMock = jasmine.createSpyObj<IdlService>(['clone']);
+ const orgMock = jasmine.createSpyObj<OrgService>(['get']);
+ const authServiceMock = jasmine.createSpyObj<AuthService>(['user']);
+ const formatServiceMock = jasmine.createSpyObj<FormatService>(['transform']);
+ const storeServiceMock = jasmine.createSpyObj<StoreService>(['setLocalItem']);
+ const fileExportServiceMock = jasmine.createSpyObj<FileExportService>(['exportFile']);
+ const toastServiceMock = jasmine.createSpyObj<ToastService>(['success']);
+ const volCopyServiceMock = jasmine.createSpyObj<VolCopyService>(['copyStatIsMagic']);
+
+ beforeEach(() => {
+ component = new CopyAttrsComponent(idlMock, orgMock, authServiceMock,
+ formatServiceMock, storeServiceMock, fileExportServiceMock,
+ toastServiceMock, volCopyServiceMock);
+ component.copyTemplateCbox = jasmine.createSpyObj<ComboboxComponent>(['entries']);
+ component.copyTemplateCbox.selected = {id: 0};
+ });
+ describe('#applyTemplate', () => {
+ describe('status field', () => {
+ it('does not apply a magic status to an item', waitForAsync(() => {
+ let template = { "status": 1 };
+ volCopyServiceMock.templates = [template];
+ volCopyServiceMock.copyStatIsMagic.and.returnValue(true);
+ component.batchAttrs = new QueryList();
+
+ spyOn(component, 'applyTemplate').and.callThrough();
+ spyOn(component, 'applyCopyValue').and.callThrough();
+
+ component.applyTemplate();
+ expect(component.applyCopyValue).not.toHaveBeenCalled();
+ }));
+ });
+ })
+});
import {Component, Input, OnInit, AfterViewInit, ViewChild,
EventEmitter, Output, QueryList, ViewChildren} from '@angular/core';
-import {Router, ActivatedRoute} from '@angular/router';
import {SafeUrl} from '@angular/platform-browser';
import {IdlObject, IdlService} from '@eg/core/idl.service';
-import {EventService} from '@eg/core/event.service';
import {OrgService} from '@eg/core/org.service';
import {StoreService} from '@eg/core/store.service';
-import {NetService} from '@eg/core/net.service';
import {AuthService} from '@eg/core/auth.service';
-import {PcrudService} from '@eg/core/pcrud.service';
-import {HoldingsService} from '@eg/staff/share/holdings/holdings.service';
import {VolCopyContext} from './volcopy';
import {VolCopyService} from './volcopy.service';
import {FormatService} from '@eg/core/format.service';
@Output() canSaveChange: EventEmitter<boolean> = new EventEmitter<boolean>();
constructor(
- private router: Router,
- private route: ActivatedRoute,
- private evt: EventService,
private idl: IdlService,
private org: OrgService,
- private net: NetService,
private auth: AuthService,
- private pcrud: PcrudService,
- private holdings: HoldingsService,
private format: FormatService,
private store: StoreService,
private fileExport: FileExportService,
const value = template[field];
if (value === null || value === undefined) { return; }
+ if (field === 'status' && this.volcopy.copyStatIsMagic(value)) { return; }
if (field === 'statcats') {
Object.keys(value).forEach(catId => {