Pankaj Parkar
Indian | 30 | Ex MVP | Angular GDE
Technical Lead
Synerzip Softech India PVT LTD
@pankajparkar
@pankajparkar
@pankajparkar
@pankajparkar
@pankajparkar
expect($('status').text())
.toBe('Done'))
expect(component.completed)
.toBe(true)
Setup
Spec
@pankajparkar
BeforeEach
It
@pankajparkar
One test should not be depend on other state
This will make test hard to maintain, if any of it gets change may result in error.
Consider both use cases
Mock / Stub / Spies - Test doubles
Source: https://cdn-images-1.medium.com/max/1600/0*snrzYwepyaPu3uC9.png
@pankajparkar
Spec Runner
Fake / Test Doubles / Dependencies
Spec
Spec
Spec
Spec
Spec
Pass
Pass
Pass
Pass
Failed
@pankajparkar
@pankajparkar
@pankajparkar
@pankajparkar
function mergeAndSaveExcelFiles (files) {
const mergedFile = loadFiles(files)
return mergedFile;
}
function loadFiles (files) {
const [file1, file2] = files
const file1Content = File.load(file1)
const file2Content = File.load(file2)
return mergeFiles(file1Content, file2Content)
}
function mergeFiles (file1Content, file2Content) {
const newMergedFileContent = File.merge(file1Content, file2Content)
const newFile = File.create('mergeFile.xlsx', newMergedFileContent)
return newFile
}
@pankajparkar
function mergeAndSaveExcelFiles (files) {
// load files
const {file1Content, file2Content} = loadFiles(files)
// merge files
const newFileContent = mergeFiles(file1Content, file2Content)
// save files
const mergedFile = saveFile('mergeFile.xlsx', newFileContent)
return mergedFile;
}
function loadFiles (files) {
const [file1, file2] = files
const file1Content = File.load(file1)
const file2Content = File.load(file2)
return {file1Content, file2Content}
}
function mergeFiles (file1Content, file2Content) {
const newMergedFileContent = File.merge(file1Content, file2Content)
return newMergedFileContent;
}
function saveFile(fileName, content) {
const newFile = File.create(fileName, newMergedFileContent)
return newFile
}
@pankajparkar
https://github.com/pankajparkar/weather-cast
@pankajparkar
@pankajparkar
By Pankaj Parkar