zefoy / ngx-dropzone-wrapper

Angular wrapper library for Dropzone
MIT License
174 stars 51 forks source link

ng test fails #98

Closed ronnykristiansen closed 6 years ago

ronnykristiansen commented 6 years ago

Hi, More of a question thna a bug but my upload component that uses the ngx-dropzone-wrapper fails ng test, its only html markup is <dropzone [config]="config" [message]="'Click or drag images here to upload'" (error)="onUploadError($event)" (success)="onUploadSuccess($event)" (sending)="onSending($event)"> </dropzone> How does i wire this in my spec.ts file for the component? As far as i can see there is noe test files on your running example.

Can't bind to 'dropzone' since it isn't a known property of 'div'. Can't bind to 'disabled' since it isn't a known property of 'div'. Can't bind to 'config' since it isn't a known property of 'dropzone'.

'dropzone' is not a known element:

  1. If 'dropzone' is an Angular component, then verify that it is part of this module.
  2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("[ERROR ->]<dropzone [config]="config" [message]="'Click or drag images here to upload'" (error)="onUploadError")
sconix commented 6 years ago

That's more of an Angular related question than related to this library and sorry that I can not help you with this since I am not that familiar with the unit tests. I don't see any problems with this wrapper regarding the unit tests since I know how they work, but since I have not made unit tests for components that use this wrapper I can not offer any solution without testing the solution myself to be sure that my advice would be correct. And at least at the moment I am that busy that I don't have time to do even a simple unit test sample.

plushkinqt commented 6 years ago

There are two solutions to run unit tests with dropzone wrapper: define NO_ERRORS_SCHEMA in your TestBed then all unknown properties of elements will be ignored(works for all components, not only dropzone wrapper), second option import DropzoneModule.

Example 1:

import { NO_ERRORS_SCHEMA } from '@angular/core';
TestBed.configureTestingModule({
  declarations: [ ... ],
  imports: [ ... ],
  schemas: [ NO_ERRORS_SCHEMA ]
})

Example 2:

import { DropzoneModule } from 'ngx-dropzone-wrapper';
TestBed.configureTestingModule({
  declarations: [ ... ],
  imports: [ DropzoneModule ],
  schemas: [ ... ]
})