Skip to content

Commit

Permalink
Merge pull request #2861 from storybooks/tmeasday/fix-knobs-test
Browse files Browse the repository at this point in the history
Use UTC timezone in formatting too for knobs test
  • Loading branch information
Tom Coleman authored Jan 29, 2018
2 parents f8bd011 + d343b37 commit 4ea7273
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/official-storybook/stories/addon-knobs.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ storiesOf('Addons|Knobs.withKnobsOptions', module)
const intro = `My name is ${name}, I'm ${age} years old, and my favorite fruit is ${fruit}.`;
const style = { backgroundColor, ...otherStyles };
const salutation = nice ? 'Nice to meet you!' : 'Leave me alone!';
const dateOptions = { year: 'numeric', month: 'long', day: 'numeric' };
const dateOptions = { year: 'numeric', month: 'long', day: 'numeric', timeZone: 'UTC' };

return (
<div style={style}>
Expand Down
5 changes: 3 additions & 2 deletions examples/polymer-cli/src/stories/advanced.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,21 @@ storiesOf('Advanced/Addon Knobs', module)
const fruit = select('Fruit', fruits, 'apple');
const price = number('Price', 2.25);
const colour = color('Border', 'deeppink');
const today = date('Today', new Date('Jan 20 2017'));
const today = date('Today', new Date('Jan 20 2017 GMT+0'));
const items = array('Items', ['Laptop', 'Book', 'Whiskey']);
const nice = boolean('Nice', true);

const stockMessage = stock
? `I have a stock of ${stock} ${fruit}, costing &dollar;${price} each.`
: `I'm out of ${fruit}${nice ? ', Sorry!' : '.'}`;
const dateOptions = { year: 'numeric', month: 'long', day: 'numeric', timeZone: 'UTC' };

button('Arbitrary action', action('You clicked it!'));

return `
<div style="border:2px dotted ${colour}; padding: 8px 22px; border-radius: 8px">
<h1>My name is ${name},</h1>
<h3>today is ${new Date(today).toLocaleDateString()}</h3>
<h3>today is ${new Date(today).toLocaleDateString('en-US', dateOptions)}</h3>
<p>${stockMessage}</p>
<p>Also, I have:</p>
<ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ exports[`Storyshots Addon Knobs All knobs 1`] = `
</h1>

<h3>
today is 2017-1-20
today is January 20, 2017
</h3>

<p>
Expand Down
6 changes: 4 additions & 2 deletions examples/vue-kitchen-sink/src/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,22 +223,24 @@ storiesOf('Addon Knobs', module)
const price = number('Price', 2.25);

const colour = color('Border', 'deeppink');
const today = date('Today', new Date('Jan 20 2017'));
const today = date('Today', new Date('Jan 20 2017 GMT+0'));
const items = array('Items', ['Laptop', 'Book', 'Whiskey']);
const nice = boolean('Nice', true);

const stockMessage = stock
? `I have a stock of ${stock} ${fruit}, costing &dollar;${price} each.`
: `I'm out of ${fruit}${nice ? ', Sorry!' : '.'}`;
const salutation = nice ? 'Nice to meet you!' : 'Leave me alone!';
const dateOptions = { year: 'numeric', month: 'long', day: 'numeric', timeZone: 'UTC' };


button('Arbitrary action', action('You clicked it!'));

return {
template: `
<div style="border:2px dotted ${colour}; padding: 8px 22px; border-radius: 8px">
<h1>My name is ${name},</h1>
<h3>today is ${new Date(today).toLocaleDateString()}</h3>
<h3>today is ${new Date(today).toLocaleDateString('en-US', dateOptions)}</h3>
<p>${stockMessage}</p>
<p>Also, I have:</p>
<ul>
Expand Down

0 comments on commit 4ea7273

Please sign in to comment.