Skip to content

Commit

Permalink
PD-561: Logic to determine when to display Realm/Stitch (#302)
Browse files Browse the repository at this point in the history
* realm or stitch logic

* changeset

* second tab name

* another little fix

* fix tests

* fix tests
  • Loading branch information
bruugey authored Mar 9, 2020
1 parent 208d881 commit 3f7719e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/silver-wombats-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/mongo-nav': patch
---

Add logic to determine whether to display Realm or Stitch
28 changes: 27 additions & 1 deletion packages/mongo-nav/src/project-nav/ProjectNav.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
hostDefaults,
constructProjectURL,
} from '../data';
import ProjectNav from './ProjectNav';
import ProjectNav, { displayProductName } from './ProjectNav';
import { startCase } from 'lodash';

// types
Expand Down Expand Up @@ -169,4 +169,30 @@ describe('packages/mongo-nav/src/project-nav', () => {

testForAlerts(alerts, true);
});

describe('when the date is before MongoDB World', () => {
const testDate = new Date('March 20, 2020 0:00:00');

test('Stitch is displayed in the ProjectNav', () => {
const productName = displayProductName(testDate);
expect(productName).toBe('Stitch');
});
});

describe('when the date is the day of MongoDB World', () => {
const mdbworld = new Date('May 4, 2020 0:00:00');

test('Realm is displayed in the ProjectNav', () => {
const productName = displayProductName(mdbworld);
expect(productName).toBe('Realm');
});
});

describe('when the date is after MongoDB World', () => {
const testDate = new Date('May 5, 2020 0:00:00');
test('Realm is displayed in the ProjectNav', () => {
const productName = displayProductName(testDate);
expect(productName).toBe('Realm');
});
});
});
14 changes: 13 additions & 1 deletion packages/mongo-nav/src/project-nav/ProjectNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,18 @@ const tooltipStyles = css`
text-align: center;
`;

export function displayProductName(today = new Date(Date.now())) {
const mdbworld = new Date('May 4, 2020 0:00:00');

if (today >= mdbworld) {
return 'Realm';
}

return 'Stitch';
}

const secondTabName = displayProductName();

interface ProjectNavInterface {
current?: CurrentProjectInterface;
data?: Array<ProjectInterface>;
Expand Down Expand Up @@ -358,7 +370,7 @@ export default function ProjectNav({
glyph="Stitch"
/>
)}
Realm
{secondTabName}
</a>
</li>
)}
Expand Down

0 comments on commit 3f7719e

Please sign in to comment.