Skip to content

Commit

Permalink
fix: dynamic date generation for <Package /> component test
Browse files Browse the repository at this point in the history
fix: adds <Package /> component snapshot
  • Loading branch information
ayusharma committed Jun 18, 2018
1 parent 8e16bbc commit e5ea0c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/webui/components/__snapshots__/package.spec.js.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Package /> component should load the component 1`] = `"<section class=\\"package\\"><a href=\\"detail/verdaccio\\"><div class=\\"header\\"><div class=\\"title\\"><h1>verdaccio <span class=\\"el-tag el-tag--gray\\">v1.0.0</span></h1></div><div role=\\"author\\" class=\\"author\\">By: Sam</div></div><div class=\\"footer\\"><p class=\\"description\\">Private NPM repository</p></div><div class=\\"details\\"><div class=\\"license\\">MIT</div></div></a></section>"`;
exports[`<Package /> component should load the component 1`] = `"<section class=\\"package\\"><a href=\\"detail/verdaccio\\"><div class=\\"header\\"><div class=\\"title\\"><h1>verdaccio <span class=\\"el-tag el-tag--gray\\">v1.0.0</span></h1></div><div role=\\"author\\" class=\\"author\\">By: Sam</div></div><div class=\\"footer\\"><p class=\\"description\\">Private NPM repository</p></div><div class=\\"details\\"><div class=\\"homepage\\">Published about 1 month ago</div><div class=\\"license\\">MIT</div></div></a></section>"`;
11 changes: 11 additions & 0 deletions test/webui/components/package.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@ import { mount } from 'enzyme';
import Package from '../../../src/webui/src/components/Package';
import { BrowserRouter } from 'react-router-dom';

/**
* Generates one month back date from current time
* @return {object} date object
*/
const dateOneMonthAgo = () => {
const date = new Date();
date.setMonth(date.getMonth() - 1);
return date;
}

describe('<Package /> component', () => {
it('should load the component', () => {
const props = {
name: 'verdaccio',
version: '1.0.0',
time: dateOneMonthAgo(),
license: 'MIT',
description: 'Private NPM repository',
author: { name: 'Sam' }
Expand Down

0 comments on commit e5ea0c2

Please sign in to comment.