Skip to content

Commit

Permalink
100% test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
timkeane committed May 31, 2019
1 parent efd7a5c commit 7c36696
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions __tests__/App.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,8 @@ describe('zoomToExtent', () => {

describe('zoomTo', () => {
const mockPopup = {
hide: jest.fn()
hide: jest.fn(),
showFeature: jest.fn()
}
const mockTabs = {
open: jest.fn()
Expand All @@ -588,9 +589,10 @@ describe('zoomTo', () => {
let tabs

beforeEach(() => {
tabs = $('<div id="tabs"><div class="btns><h2></h2><h2></h2></div></div>')
tabs = $('<div id="tabs"><div class="btns"><h2></h2><h2></h2></div></div>')
$('body').append(tabs)
mockPopup.hide.mockClear()
mockPopup.showFeature.mockClear()
mockTabs.open.mockClear()
mockMap.handlers = {}
})
Expand All @@ -599,8 +601,8 @@ describe('zoomTo', () => {
tabs.remove()
})

test.only('zoomTo', () => {
expect.assertions(11)
test('zoomTo', () => {
expect.assertions(15)

mockContent.messages.active = 'true'

Expand All @@ -611,7 +613,6 @@ describe('zoomTo', () => {
app.zoomToExtent = jest.fn()

$('#tabs .btns h2:first-of-type').css('display', 'block')
console.warn($('#tabs .btns h2:first-of-type')[0],$('#tabs .btns h2:first-of-type').css('display'));
app.zoomTo(examplePOD1)

expect(mockPopup.hide).toHaveBeenCalledTimes(1)
Expand All @@ -621,9 +622,12 @@ describe('zoomTo', () => {
expect(app.tabs.open).toHaveBeenCalledTimes(1)
expect(app.tabs.open.mock.calls[0][0]).toBe('#map')

mockMap.trigger('moveend')

expect(app.popup.showFeature).toHaveBeenCalledTimes(1)
expect(app.popup.showFeature.mock.calls[0][0]).toBe(examplePOD1)

$('#tabs .btns h2:first-of-type').css('display', 'none')
console.warn($('#tabs .btns h2:first-of-type')[0],$('#tabs .btns h2:first-of-type').css('display'));
app.zoomTo(examplePOD2)

expect(mockPopup.hide).toHaveBeenCalledTimes(2)
Expand All @@ -632,5 +636,10 @@ describe('zoomTo', () => {
expect(app.zoomToExtent.mock.calls[1][1]).toBe(4)
expect(app.tabs.open).toHaveBeenCalledTimes(1)

mockMap.trigger('moveend')

expect(app.popup.showFeature).toHaveBeenCalledTimes(2)
expect(app.popup.showFeature.mock.calls[1][0]).toBe(examplePOD2)

})
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pods",
"version": "0.4.1",
"version": "0.4.2",
"description": "",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 7c36696

Please sign in to comment.