diff --git a/public/index.html b/public/index.html index 8a25eaf..91d3081 100644 --- a/public/index.html +++ b/public/index.html @@ -51,5 +51,9 @@ function openInCbox(url){ alert('Would have opened in colorbox on server: ' + url); } + initTemplateBrowser({ + divId: 'root', + + }) diff --git a/specs/features/users-can-open-templates.spec.js b/specs/features/users-can-open-templates.spec.js new file mode 100644 index 0000000..b0dfc41 --- /dev/null +++ b/specs/features/users-can-open-templates.spec.js @@ -0,0 +1,19 @@ +import React from 'react'; +import { mount } from 'enzyme'; +import Browser from '../../src/components/Browser'; +import create from '../spec-helpers'; + +describe('Feature: Users can open templates', () => { + it('calls the attached function with expected params', () => { + const templates = [ + create('template', {id: 23, type: 'TextOnly'}) + ]; + const openTemplate = jest.fn( () => {} ); + const app = mount(); + + app.find('Template').simulate('click'); + + expect(openTemplate.mock.calls[0]).toEqual([23, 'TextOnly']); + }); + +}); diff --git a/src/components/Browser.js b/src/components/Browser.js index cc1b451..c7d6da2 100644 --- a/src/components/Browser.js +++ b/src/components/Browser.js @@ -77,7 +77,12 @@ class Browser extends Component { render() { const tags = this.getTags(); const filteredTemplates = this.getFilteredTemplates().map( (template, i) => { - return(