Skip to content

Commit

Permalink
test(Feed): fix tests for fixed props
Browse files Browse the repository at this point in the history
  • Loading branch information
levithomason committed Oct 2, 2016
1 parent f519e1a commit 2f10ecc
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 33 deletions.
14 changes: 6 additions & 8 deletions test/specs/views/Feed/FeedContent-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import faker from 'faker'
import React from 'react'

import * as common from 'test/specs/commonTests'
Expand All @@ -14,12 +13,12 @@ describe('FeedContent', () => {
common.implementsShorthandProp(FeedContent, {
propKey: 'date',
ShorthandComponent: FeedDate,
mapValueToProps: val => ({ date: val }),
mapValueToProps: val => ({ content: val }),
})
common.implementsShorthandProp(FeedContent, {
propKey: 'summary',
ShorthandComponent: FeedSummary,
mapValueToProps: val => ({ summary: val }),
mapValueToProps: val => ({ content: val }),
})
common.implementsShorthandProp(FeedContent, {
propKey: 'extraImages',
Expand All @@ -29,19 +28,18 @@ describe('FeedContent', () => {
common.implementsShorthandProp(FeedContent, {
propKey: 'extraText',
ShorthandComponent: FeedExtra,
mapValueToProps: val => ({ text: val }),
mapValueToProps: val => ({ text: true, content: val }),
})
common.implementsShorthandProp(FeedContent, {
propKey: 'meta',
ShorthandComponent: FeedMeta,
mapValueToProps: val => ({ meta: val }),
mapValueToProps: val => ({ content: val }),
})

common.rendersChildren(FeedContent)

it('renders text with content prop', () => {
const text = faker.hacker.phrase()

shallow(<FeedContent content={text} />).should.contain.text(text)
shallow(<FeedContent content='foo' />)
.should.contain.text('foo')
})
})
14 changes: 5 additions & 9 deletions test/specs/views/Feed/FeedExtra-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import _ from 'lodash'
import faker from 'faker'
import React from 'react'

import * as common from 'test/specs/commonTests'
Expand All @@ -11,15 +9,13 @@ describe('FeedExtra', () => {
common.propKeyOnlyToClassName(FeedExtra, 'text')
common.rendersChildren(FeedExtra)

it('renders text with text prop', () => {
const text = faker.hacker.phrase()

shallow(<FeedExtra text={text} />).should.contain(text)
it('renders text with content prop', () => {
shallow(<FeedExtra content='foo' />)
.should.contain.text('foo')
})

it('renders <img> with images prop', () => {
const images = _.times(3, () => faker.image.imageUrl())

shallow(<FeedExtra images={images} />).should.have.exactly(3).descendants('img')
shallow(<FeedExtra images={['a', 'b', 'c']} />)
.should.have.exactly(3).descendants('img')
})
})
8 changes: 3 additions & 5 deletions test/specs/views/Feed/FeedLike-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import faker from 'faker'
import React from 'react'

import * as common from 'test/specs/commonTests'
Expand All @@ -9,9 +8,8 @@ describe('FeedLike', () => {
common.implementsIconProp(FeedLike)
common.rendersChildren(FeedLike)

it('renders text with like prop', () => {
const text = faker.hacker.phrase()

shallow(<FeedLike like={text} />).should.contain.text(text)
it('renders text with content prop', () => {
shallow(<FeedLike content='foo' />)
.should.contain.text('foo')
})
})
8 changes: 3 additions & 5 deletions test/specs/views/Feed/FeedMeta-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import faker from 'faker'
import React from 'react'

import * as common from 'test/specs/commonTests'
Expand All @@ -11,12 +10,11 @@ describe('FeedMeta', () => {
common.implementsShorthandProp(FeedMeta, {
propKey: 'like',
ShorthandComponent: FeedLike,
mapValueToProps: val => ({ like: val }),
mapValueToProps: val => ({ content: val }),
})

it('renders text with meta prop', () => {
const text = faker.hacker.phrase()

shallow(<FeedMeta meta={text} />).should.contain.text(text)
shallow(<FeedMeta content='foo' />)
.should.contain.text('foo')
})
})
16 changes: 10 additions & 6 deletions test/specs/views/Feed/FeedSummary-test.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import faker from 'faker'
import React from 'react'

import * as common from 'test/specs/commonTests'
import FeedSummary from 'src/views/Feed/FeedSummary'
import FeedDate from 'src/views/Feed/FeedDate'
import FeedUser from 'src/views/Feed/FeedUser'

describe('FeedSummary', () => {
common.isConformant(FeedSummary)
common.rendersChildren(FeedSummary)
common.implementsShorthandProp(FeedSummary, {
propKey: 'date',
ShorthandComponent: FeedDate,
mapValueToProps: val => ({ date: val }),
mapValueToProps: val => ({ content: val }),
})
common.implementsShorthandProp(FeedSummary, {
propKey: 'user',
ShorthandComponent: FeedUser,
mapValueToProps: val => ({ content: val }),
})

it('renders text with summary prop', () => {
const text = faker.hacker.phrase()

shallow(<FeedSummary summary={text} />).should.contain.text(text)
it('renders text with content prop', () => {
shallow(<FeedSummary content='foo' />)
.should.contain.text('foo')
})
})

0 comments on commit 2f10ecc

Please sign in to comment.