Skip to content

Instantly share code, notes, and snippets.

@night-fury-rider
Last active May 31, 2020 04:31
Show Gist options
  • Save night-fury-rider/85f54040b108aaa4a5bcc0d0c493a1d2 to your computer and use it in GitHub Desktop.
Save night-fury-rider/85f54040b108aaa4a5bcc0d0c493a1d2 to your computer and use it in GitHub Desktop.
Unit testing Angular Application using Jasmine - Util Service spec
import { TestBed } from '@angular/core/testing';
import * as globalmocks from '../globalmocks';
import { UvUtilService } from './uv-util.service';
describe('UvUtilService', () => {
let service: UvUtilService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(UvUtilService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
it('areArraysEqual should check Arrays are Equal or not', () => {
let arr1: any;
let arr2: any;
arr1 = ['Yuvraj'];
arr2 = ['Jon'];
expect(service.areArraysEqual(arr1, arr2)).toBeFalsy();
arr1 = ['Yuvraj'];
arr2 = ['Yuvraj'];
expect(service.areArraysEqual(arr1, arr2)).toBeTruthy();
arr1 = [{
name: 'Yuvraj'
}];
arr2 = [{
name: 'Jon'
}];
expect(service.areArraysEqual(arr1, arr2)).toBeFalsy();
arr1 = [{
name: 'Jon'
}];
arr2 = [{
name: 'Jon'
}];
expect(service.areArraysEqual(arr1, arr2)).toBeTruthy();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment