Last active
May 31, 2020 04:31
-
-
Save night-fury-rider/85f54040b108aaa4a5bcc0d0c493a1d2 to your computer and use it in GitHub Desktop.
Unit testing Angular Application using Jasmine - Util Service spec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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