import { TestBed } from '@angular/core/testing';
import { MyCantiService } from './my-canti.service';
import { Storage } from '@ionic/storage-angular';
import { CantiService } from './canti.service';
import { ToastController } from '@ionic/angular';

describe('MyCantiService', () => {
  let service: MyCantiService;
  let mockStorage: any;
  let mockCantiService: any;
  let mockToastCtrl: any;

  beforeEach(() => {
    mockStorage = jasmine.createSpyObj('Storage', ['create', 'get', 'set']);
    mockStorage.get.and.returnValue(Promise.resolve([]));
    mockStorage.set.and.returnValue(Promise.resolve());

    mockCantiService = jasmine.createSpyObj('CantiService', ['getStorage']);
    mockCantiService.getStorage.and.returnValue(mockStorage);

    mockToastCtrl = jasmine.createSpyObj('ToastController', ['create']);
    mockToastCtrl.create.and.returnValue(Promise.resolve({
      present: jasmine.createSpy('present').and.returnValue(Promise.resolve())
    }));

    TestBed.configureTestingModule({
      providers: [
        MyCantiService,
        { provide: Storage, useValue: mockStorage },
        { provide: CantiService, useValue: mockCantiService },
        { provide: ToastController, useValue: mockToastCtrl }
      ]
    });
    service = TestBed.inject(MyCantiService);
  });

  it('should be created', () => {
    expect(service).toBeTruthy();
  });
});
