Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bfa1d06
Adds radio button atom and places it on header
lumodon Apr 12, 2017
c6d9df5
Creates form-checkbox
TrevorJamesH Apr 11, 2017
bec9579
Adds checkbox atom
lumodon Apr 11, 2017
1f88a9a
Merge branch '75-radiobuttons' into 75-checkboxed
lumodon Apr 12, 2017
5bac881
WIP testing
benjaminpettus Apr 12, 2017
6b44420
WIP testing eod 4/12
benjaminpettus Apr 13, 2017
95bdcff
#90 WIP Front-End Testing
benjaminpettus Apr 13, 2017
c84e765
#90 WIP testing
benjaminpettus Apr 13, 2017
812ffe0
Merge pull request #1 from benjaminpettus/testing
benjaminpettus Apr 13, 2017
3aa5255
Adds form molecule
TrevorJamesH Apr 12, 2017
4d3619e
Fixes up form to modify state from input of each given option
lumodon Apr 13, 2017
96911f1
Sets default values to all form inputs
lumodon Apr 13, 2017
611a939
Fixes header to use two inputs
lumodon Apr 13, 2017
8655d76
Removed iterators that weren't being used
lumodon Apr 13, 2017
ed89192
Adds implementation example to Form
lumodon Apr 13, 2017
6303e62
#90 WIP game page
benjaminpettus Apr 13, 2017
ec730ee
Moved init function calls to contructor
TrevorJamesH Apr 14, 2017
071f58c
Merge branch 'master' into 75-forms-inputs
lumodon Apr 14, 2017
58c580c
Merge branch '75-forms-inputs' of github.com:TrevorJamesH/interview-a…
lumodon Apr 14, 2017
a10c459
#90 WIP testing - working on landing page
benjaminpettus Apr 14, 2017
15de742
Merge pull request #2 from benjaminpettus/testing
benjaminpettus Apr 14, 2017
77b8f7d
Squashed commit of the following:
lumodon Apr 14, 2017
7003649
Merge branch 'their-master' into merge-conflict-resolver
lumodon Apr 14, 2017
b683c4d
Removes left over git merge conflict text
lumodon Apr 14, 2017
c57c9be
Merge pull request #2 from TrevorJamesH/merge-conflict-resolver
lumodon Apr 14, 2017
7d060de
Merge branch 'master' of https://github.com/GuildCrafts/interview-app
lumodon Apr 14, 2017
e39337a
Creates form test. Still WIP
lumodon Apr 14, 2017
1b89173
fix me
lumodon Apr 14, 2017
0356932
Tests all the props being in. Todo left behind for testing state
lumodon Apr 14, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
JWT_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnk0u5Aag3eJk3FaiG9H+\nv/NLRjiZxFXGJBoOO5Zhal1j8tk1D1vkWRMk+KdCjN998s//62kwYMLkAjOuEoCc\n4Lb6hCeHVIgL+nX9JOxEny0Zi6Koli1KnyQNUZ7vVYHf5NZ7k1h6MShYIzhUPdks\ntiE9nQMtP18JBupccES986iMZw8hra3AGjTBXR6siRePnBa84rYlPhzETjZX4jf6\nM+aDI7+KY3ztrkcBSQL7sbPdILBepBzxHCN1uqUBoYbVTYPZYMmaGsK553KcVds2\nB83LAy626KRAD7Sp1/NwgRIcL55bB1xef/Q+qjSnIOGd4r2JkmjmNLEM4A0p1rEo\nFQIDAQAB\n-----END PUBLIC KEY-----"
2 changes: 1 addition & 1 deletion go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}

function reset_db {
env=${1:-test}
env=${1:-test}q
dbname=interviewdb-${env}
dropdb ${dbname}
createdb ${dbname}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"devDependencies": {
"body-parser": "^1.17.1",
"chai": "^3.5.0",
"chai-enzyme": "^0.6.1",
"chai-http": "^3.0.0",
"dotenv": "^4.0.0",
"enzyme": "^2.8.0",
Expand Down
4 changes: 2 additions & 2 deletions src/browser/components/common/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export default class Routes extends Component {
}

const LandingComponent = (props, state, params) =>
<Landing profile={fakeProfile} {...props} stats={fakeStats} {...props}/>
<Landing profile={fakeProfile} {...props} stats={fakeStats} />

const GameOptionsComponent = (props, state, params) =>
<GameOptions profile={fakeProfile} {...props} stats={fakeStats} {...props} />
<GameOptions profile={fakeProfile} {...props} stats={fakeStats} />

const ProfileComponent = (props, state, params) =>
<Profile profile={fakeProfile} {...props} stats={fakeStats} {...props} />
Expand Down
6 changes: 0 additions & 6 deletions src/browser/components/foo.js

This file was deleted.

48 changes: 23 additions & 25 deletions src/browser/components/molecules/form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ export default class Form extends Component{
this.state = {
input: {}
}

const form = this.props.inputModules.map( inputModule => {
return {'Input': this.initTextInput.bind(this, inputModule),
'Checkbox': this.initCheckbox.bind(this, inputModule),
'Radio': this.initRadio.bind(this, inputModule),
'Select': this.initSelect.bind(this, inputModule)
}[inputModule.type]()
})
this.state.form = form
}

parseName(inputModule, option){
Expand All @@ -63,9 +72,9 @@ export default class Form extends Component{
}

initTextInput(inputModule) {
let domElement = (<FormInput
prompt={inputModule.prompt}
placeholder={inputModule.placeholder}
let domElement = (<FormInput
prompt={inputModule.prompt}
placeholder={inputModule.placeholder}
onChange={this.handleChange.bind(this)}/>
)

Expand All @@ -76,9 +85,9 @@ export default class Form extends Component{
}

initCheckbox(inputModule) {
let domElement = (<FormCheckbox
prompt={inputModule.prompt}
options={inputModule.options}
let domElement = (<FormCheckbox
prompt={inputModule.prompt}
options={inputModule.options}
onChange={this.handleChange.bind(this)}/>)

let currentState = this.state
Expand All @@ -90,9 +99,9 @@ export default class Form extends Component{
}

initRadio(inputModule) {
let domElement = (<FormRadio
prompt={inputModule.prompt}
options={inputModule.options}
let domElement = (<FormRadio
prompt={inputModule.prompt}
options={inputModule.options}
onChange={this.handleChange.bind(this)}
/>)
let currentState = this.state
Expand All @@ -104,11 +113,11 @@ export default class Form extends Component{

initSelect(inputModule) {
let domElement = (
<FormSelect
prompt={inputModule.prompt}
options={inputModule.options}
isOptionRequired={inputModule.isOptionRequired}
onChange={this.handleChange.bind(this) }
<FormSelect
prompt={inputModule.prompt}
options={inputModule.options}
isOptionRequired={inputModule.isOptionRequired}
onChange={this.handleChange.bind(this) }
passId={inputModule.id}
/>)
let currentState = this.state
Expand All @@ -117,17 +126,6 @@ export default class Form extends Component{
return domElement
}

componentDidMount() {
const form = this.props.inputModules.map( inputModule => {
return {'Input': this.initTextInput.bind(this, inputModule),
'Checkbox': this.initCheckbox.bind(this, inputModule),
'Radio': this.initRadio.bind(this, inputModule),
'Select': this.initSelect.bind(this, inputModule)
}[inputModule.type]()
})
this.setState({form: form})
}

render(){
return(
<form className="uk-form-horizontal uk-margin-large">
Expand Down
2 changes: 1 addition & 1 deletion src/browser/components/molecules/prompt-input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class AddInput extends Component {

render() {
return (
<div>
<div className="add-input">
<button className="uk-button uk-button-default" onClick={this.addInput}>
Add a Hint
</button>
Expand Down
2 changes: 0 additions & 2 deletions src/browser/components/molecules/scorecard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ export default class Scorecard extends Component {
const {questions, answered, skipped} = this.props
return (
<div className="uk-grid">

<div className="">Correct: {answered.length}/{questions.length}</div>
<div className="">Skipped: {skipped.length}/{questions.length}</div>

</div>
)
}
Expand Down
6 changes: 3 additions & 3 deletions src/browser/components/pages/game/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ export default class Game extends Component {

<div className="uk-flex uk-grid">
<div className="uk-flex-first">
<button className="uk-button uk-button-primary"
<button id="correct" className="uk-button uk-button-primary"
onClick={this.incrementQuestionState.bind(this, 'answered')}>Correct</button>
</div>
<div className="uk-flex">
<button className="uk-button uk-button-danger"
<button id="skipped" className="uk-button uk-button-danger"
onClick={this.incrementQuestionState.bind(this, 'skipped')}>Skip</button>
</div>
<div className="uk-flex">
<div id="show" className="uk-flex">
<button className="uk-button-secondary uk-button" onClick={this.toggleProperty.bind(this, 'showAnswer')}>Show Answer</button>
</div>
</div>
Expand Down
21 changes: 21 additions & 0 deletions test/browser/atoms/form_input_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'
import { expect } from 'chai'
import { shallow, mount } from 'enzyme'
import { jsdom } from 'jsdom'

import FormInput from '../../../src/browser/components/atoms/form-input/index'

describe('<FormInput />', () => {

it('should return a div', () => {
const wrapper = shallow(<FormInput />)
expect(wrapper.find('div.uk-form-controls')).to.have.length(1)
})

it('should have an input field inside the main div', () => {
const wrapper = mount(<FormInput />)
expect(wrapper.children()).to.have.length(1)
expect(wrapper.find('div.uk-form-controls').childAt(0).type()).to.equal('input')
expect(wrapper.find('#form-horizontal-text')).to.have.length(1)
})
})
22 changes: 22 additions & 0 deletions test/browser/atoms/profile_box_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'
import { expect } from 'chai'
import { shallow, mount } from 'enzyme'
import { jsdom } from 'jsdom'

import ProfileBox from '../../../src/browser/components/atoms/profile-box/index'

describe('<ProfileBox />', () => {

it('should return a div', () => {
const wrapper = shallow(<ProfileBox />)
expect(wrapper.children()).to.have.length(1)
})

it('the child element should be a div', () => {
const wrapper = mount(<ProfileBox />)
expect(wrapper.find('div.uk-grid-small').childAt(0).type()).to.equal('div')
})



});
48 changes: 48 additions & 0 deletions test/browser/atoms/select_tag_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from 'react'
import { expect } from 'chai'
import { shallow, mount } from 'enzyme'
import { jsdom } from 'jsdom'

import SelectTag from '../../../src/browser/components/atoms/form-select/index'


describe('<SelectTag />', () => {
const label = 'difficulty'
const options = ['Javascript', 'SQL', 'http']
const value = 'SQL'

it('should return a div', () => {
const wrapper = shallow(<SelectTag options={[]} label={label} value={options[1]} />)
expect(wrapper.find('div.uk-margin')).to.have.length(1)
})

context('the outer div should contain two html elements', () => {
it('should have a label', () => {
const wrapper = mount(<SelectTag options={[]} label={label} value={options[1]} />)
expect(wrapper.find('div.uk-margin').childAt(0).type()).to.equal('label')
expect(wrapper.props().label).to.equal('difficulty')
})

it('should have a div', () => {
const wrapper = mount(<SelectTag options={[]} label={label} value={options[1]} />)
expect(wrapper.find('div.uk-margin').childAt(1).type()).to.equal('div')
})
})

context('inner divs child should be a select', () => {
it('is a selector', () => {
const wrapper = mount(<SelectTag options={[]} label={label} value={options[1]} />)
expect(wrapper.find('div.uk-form-controls').children().type()).to.equal('select')
})
it('should display a value', () => {
const wrapper = mount(<SelectTag options={[]} label={label} value={options[1]} />)
expect(wrapper.props().value).to.equal('SQL')
})
})

it('should render N+1 <option> tags', () => {
const wrapper = mount(<SelectTag options={options} label={label} />)
expect(wrapper.find('option').length).to.eql(4)
})

})
33 changes: 33 additions & 0 deletions test/browser/atoms/stat_box_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react'
import { expect } from 'chai'
import { shallow, mount } from 'enzyme'
import { jsdom } from 'jsdom'

global.document = jsdom('');
global.window = document.defaultView;

import StatBox from '../../../src/browser/components/atoms/stat-box/index'
import StatCounter from '../../../src/browser/components/atoms/stat-counter/index'

describe('<StatBox />', () => {

it('should return a div', () => {
const wrapper = shallow(<StatBox />)
expect(wrapper.find('div.uk-grid-small')).to.have.length(1)
})

context('should have a nested div', () => {
it('should have a div inside of the main div', () => {
const wrapper = mount(<StatBox />)
expect(wrapper.find('div.uk-grid-small').childAt(0).type()).to.equal('div')
expect(wrapper.find('div.uk-flex-left')).to.have.length(1)
})
})
context('inner div contains an instance of <StatCounter />', () => {
it('should render <StatCounter/>', () => {
const wrapper = mount(<StatBox />)
expect(wrapper.containsMatchingElement(<StatCounter />)).to.be.true
})
})

})
21 changes: 21 additions & 0 deletions test/browser/atoms/stat_counter_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'
import { expect } from 'chai'
import { shallow, mount } from 'enzyme'
import { jsdom } from 'jsdom'

global.document = jsdom('');
global.window = document.defaultView;

import StatCounter from '../../../src/browser/components/atoms/stat-counter/index'

describe('<StatCounter />', () => {
it('should contain a div', () => {
const wrapper = shallow(<StatCounter />)
expect(wrapper.find('div.uk-margin-small-left')).to.have.length(1)
})

it('should contain a nested div', () => {
const wrapper = mount(<StatCounter />)
expect(wrapper.find('div.uk-badge').exists()).to.be.true
})
})
13 changes: 6 additions & 7 deletions test/routes_test.js → test/browser/common/routes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ const doc = jsdom.jsdom('<!doctype html><html><body><div id="app"></div></body><
global.document = doc
global.window = doc.defaultView

import Routes from '../src/browser/components/common/router'
import Landing from '../src/browser/components/pages/landing/index'
import Scorecard from '../src/browser/components/molecules/scorecard/index'
import FormSelect from '../src/browser/components/atoms/form-select/index'
import GameOptions from '../src/browser/components/molecules/game-options/index'
import Routes from '../../../src/browser/components/common/router'
import Landing from '../../../src/browser/components/pages/landing/index'
import Scorecard from '../../../src/browser/components/molecules/scorecard/index'
import SelectTag from '../../../src/browser/components/atoms/form-select/index'
import GameOptions from '../../../src/browser/components/molecules/game-options/index'

describe('<Routes />', () => {
it('should render correct routes', () => {
const wrapper = shallow( < Routes / > )
const wrapper = shallow( < Routes / >)
const pathMap = wrapper.find(Route).reduce((pathMap, route) => {
const routeProps = route.props()
pathMap[routeProps.path] = routeProps.component
// console.log('path map::', pathMap)
return pathMap;
}, {})
expect(pathMap['/'].toString()).to.equal(Landing.toString())
Expand Down
Loading