Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiebuilds committed Mar 20, 2017
1 parent 51673ce commit 1cef038
Show file tree
Hide file tree
Showing 9 changed files with 398 additions and 360 deletions.
492 changes: 246 additions & 246 deletions __tests__/scenes/Schedule/__snapshots__/index.test.js.snap

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions __tests__/scenes/Schedule/components/Talk.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ describe('Schedule - Talk', () => {
keynote={keynote}
lightning={lightning}
onPress={() => {}}
speaker={{
name: 'Max Stoiber',
twitter: 'mxstbr',
}}
speakers={[
{
name: 'Max Stoiber',
twitter: 'mxstbr',
summary: '',
avatar: '',
},
]}
startTime="9 AM"
status={status}
title="This is a test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ exports[`Schedule - Talk renders talk types correctly 1`] = `
"overflow": "hidden",
"width": 44,
},
undefined,
null,
]
}>
<Image
source={
Object {
"uri": undefined,
"uri": "",
}
}
style={
Expand Down Expand Up @@ -340,13 +340,13 @@ exports[`Schedule - Talk renders talk types correctly 2`] = `
"overflow": "hidden",
"width": 44,
},
undefined,
null,
]
}>
<Image
source={
Object {
"uri": undefined,
"uri": "",
}
}
style={
Expand Down Expand Up @@ -513,13 +513,13 @@ exports[`Schedule - Talk renders talk types correctly 3`] = `
"overflow": "hidden",
"width": 44,
},
undefined,
null,
]
}>
<Image
source={
Object {
"uri": undefined,
"uri": "",
}
}
style={
Expand Down Expand Up @@ -726,13 +726,13 @@ exports[`Schedule - Talk renders talk types correctly 4`] = `
"overflow": "hidden",
"width": 44,
},
undefined,
null,
]
}>
<Image
source={
Object {
"uri": undefined,
"uri": "",
}
}
style={
Expand Down Expand Up @@ -976,13 +976,13 @@ exports[`Schedule - Talk renders talk types correctly 5`] = `
"overflow": "hidden",
"width": 44,
},
undefined,
null,
]
}>
<Image
source={
Object {
"uri": undefined,
"uri": "",
}
}
style={
Expand Down Expand Up @@ -1187,13 +1187,13 @@ exports[`Schedule - Talk renders talk types correctly 6`] = `
"overflow": "hidden",
"width": 44,
},
undefined,
null,
]
}>
<Image
source={
Object {
"uri": undefined,
"uri": "",
}
}
style={
Expand Down Expand Up @@ -1400,13 +1400,13 @@ exports[`Schedule - Talk renders talk types correctly 7`] = `
"overflow": "hidden",
"width": 44,
},
undefined,
null,
]
}>
<Image
source={
Object {
"uri": undefined,
"uri": "",
}
}
style={
Expand Down Expand Up @@ -1650,13 +1650,13 @@ exports[`Schedule - Talk renders talk types correctly 8`] = `
"overflow": "hidden",
"width": 44,
},
undefined,
null,
]
}>
<Image
source={
Object {
"uri": undefined,
"uri": "",
}
}
style={
Expand Down Expand Up @@ -1861,13 +1861,13 @@ exports[`Schedule - Talk renders talk types correctly 9`] = `
"overflow": "hidden",
"width": 44,
},
undefined,
null,
]
}>
<Image
source={
Object {
"uri": undefined,
"uri": "",
}
}
style={
Expand Down Expand Up @@ -2074,13 +2074,13 @@ exports[`Schedule - Talk renders talk types correctly 10`] = `
"overflow": "hidden",
"width": 44,
},
undefined,
null,
]
}>
<Image
source={
Object {
"uri": undefined,
"uri": "",
}
}
style={
Expand Down Expand Up @@ -2324,13 +2324,13 @@ exports[`Schedule - Talk renders talk types correctly 11`] = `
"overflow": "hidden",
"width": 44,
},
undefined,
null,
]
}>
<Image
source={
Object {
"uri": undefined,
"uri": "",
}
}
style={
Expand Down Expand Up @@ -2535,13 +2535,13 @@ exports[`Schedule - Talk renders talk types correctly 12`] = `
"overflow": "hidden",
"width": 44,
},
undefined,
null,
]
}>
<Image
source={
Object {
"uri": undefined,
"uri": "",
}
}
style={
Expand Down
2 changes: 1 addition & 1 deletion __tests__/scenes/Talk/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ exports[`Talk renders correctly 1`] = `
},
]
}>
8:00am
6:00pm
</Text>
</View>
<View
Expand Down
52 changes: 26 additions & 26 deletions __tests__/scenes/Talk/components/__snapshots__/Pane.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,10 @@ exports[`Talk - Pane renders correctly 1`] = `
"position": "absolute",
},
Object {
"top": -70,
"bottom": -70,
},
]
}>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"textAlign": "center",
}
}>
Conference Keynote
</Text>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
style={
Object {
"color": "#666",
"textAlign": "center",
}
}>
10:00am
</Text>
<View
style={
Object {
Expand Down Expand Up @@ -89,9 +65,33 @@ exports[`Talk - Pane renders correctly 1`] = `
},
]
}>
</Text>
</View>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"textAlign": "center",
}
}>
Conference Keynote
</Text>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
style={
Object {
"color": "#666",
"textAlign": "center",
}
}>
10:00am - Tom Occhino, Sebastian Markbage, Jing Chen
</Text>
</View>
</View>
<View
Expand Down
20 changes: 11 additions & 9 deletions __tests__/scenes/Talk/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ const talk = {
id: '',
summary: '',
title: '',
speaker: {
avatar: '',
github: '',
name: '',
twitter: '',
summary: '',
},
speakers: [
{
avatar: '',
github: '',
name: '',
twitter: '',
summary: '',
},
],
time: {
// These dates, contrary to their appearance, will end up at the same time
// each time because we're using mockdate in the setup.js file.
start: new Date(),
end: new Date(),
start: new Date(Date.UTC(2017, 3, 1, 1, 0, 0)),
end: new Date(Date.UTC(2017, 3, 1, 2, 0, 0)),
},
};

Expand Down
47 changes: 31 additions & 16 deletions app/scenes/Schedule/components/Talk/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Icon from 'react-native-vector-icons/Ionicons';
import Avatar from '../../../../components/Avatar';
import theme from '../../../../theme';
import { lighten } from '../../../../utils/color';
import type { Speaker as SpeakerType } from '../../../../types';

type Status = 'past' | 'present' | 'future';

Expand Down Expand Up @@ -88,7 +89,7 @@ type Props = {
keynote?: boolean,
lightning?: boolean,
onPress: () => mixed,
speaker: Object,
speakers: Array<SpeakerType>,
startTime: string,
status: Status,
title: string,
Expand Down Expand Up @@ -127,7 +128,7 @@ export default class Talk extends Component {
keynote,
lightning,
onPress,
speaker,
speakers,
startTime,
status,
title,
Expand Down Expand Up @@ -155,24 +156,38 @@ export default class Talk extends Component {

// subtitle variants
let subtitleText = startTime;
if (speaker) subtitleText += ` - ${speaker.name}`;
let speakersText;

let subtitle = (
<Text style={[styles.subtitle, styles.subtitleText]}>
{subtitleText}
</Text>
);
if (lightning) subtitle = <LightningSubtitle text={speaker.name} />;
else if (keynote) subtitle = <KeynoteSubtitle text={startTime} />;
if (speakers) {
speakersText = speakers.map(speaker => speaker.name).join(', ');
subtitleText += ' - ' + speakersText;
}

// avatar variants
const avatar = Array.isArray(speaker)
? speaker.map((s, i) => {
const pull = i + 1 !== speaker.length ? { marginRight: -16 } : null;
let subtitle;

return <Avatar key={s.name} source={s.avatar} style={pull} />;
if (lightning) {
subtitle = <LightningSubtitle text={speakersText} />;
} else if (keynote) {
subtitle = <KeynoteSubtitle text={startTime} />;
} else {
subtitle = (
<Text style={[styles.subtitle, styles.subtitleText]}>
{subtitleText}
</Text>
);
}

// avatar variants
const avatar = speakers
? speakers.map((speaker, index) => {
const pull = index + 1 !== speakers.length
? { marginRight: -16 }
: null;
return (
<Avatar key={speaker.name} source={speaker.avatar} style={pull} />
);
})
: <Avatar source={speaker && speaker.avatar} />;
: null;

// const avatar = <Avatar source={speaker.avatar} />;

Expand Down
Loading

0 comments on commit 1cef038

Please sign in to comment.