Skip to content
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #90 from jaebradley/game-scoreboard-test
Browse files Browse the repository at this point in the history
Game scoreboard test
  • Loading branch information
jaebradley committed Dec 26, 2016
2 parents 92aa1a0 + 7f0dcee commit 49f1f8b
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/data/GameScoreboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,13 @@ let defaults = {
export default class GameScoreboard extends Record(defaults) {

getNbaStatsFormattedStartDate() {
let userTimezone = jstz.determine().name();
return moment(this.startTimestamp).tz(Constants.DEFAULT_TIMEZONE)
.format(Constants.DEFAULT_DATE_FORMAT);
}

getLocalizedStartDateTime() {
let userTimezone = jstz.determine().name();
let formattedTime = moment(this.startTimestamp).tz(userTimezone)
return moment(this.startTimestamp).tz(jstz.determine().name())
.format(Constants.TRANSLATED_DATE_FORMAT);
return `${formattedTime}`;
}

getTvBroadcastsString() {
Expand Down
89 changes: 89 additions & 0 deletions test/GameScoreboardTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
'use es6';

import chai from 'chai';
import chaiImmutable from 'chai-immutable';
import {List} from 'immutable';
import jstz from 'jstimezonedetect';
import moment from 'moment-timezone';

import Broadcast from '../src/data/Broadcast';
import GameScoreboard from '../src/data/GameScoreboard';
import Location from '../src/data/Location';
import Matchup from '../src/data/Matchup';
import Team from '../src/data/Team';

chai.use(chaiImmutable);

let expect = chai.expect;

describe('GameScoreboard Tests', function() {
let id = 'jae';
let timestamp = moment().year(2016)
.month(12)
.date(30)
.tz('UTC')
.startOf('day');
let teamCity1 = 'Boston';
let teamNickname1 = 'Celtics';
let teamAbbreviation1 = 'BOS';
let teamCity2 = 'Los Angeles';
let teamNickname2 = 'Lakers';
let teamAbbreviation2 = 'LAL';

let homeTeam = new Team({
city: teamCity1,
nickname: teamNickname1,
abbreviation: teamAbbreviation1
});

let awayTeam = new Team({
city: teamCity2,
nickname: teamNickname2,
abbreviation: teamAbbreviation2
});

let matchup = new Matchup({
homeTeam: homeTeam,
awayTeam: awayTeam
});

let broadcastScope = 'national';
let broadcastName = 'jaebaebae';

let broadcast = new Broadcast({
scope: broadcastScope,
name: broadcastName
});

let arena = 'TD Garden';
let city = 'Boston';
let state = 'MA';
let location = new Location({
arena: arena,
city: city,
state: state
});

let scoreboard = new GameScoreboard({
id: id,
startTimestamp: timestamp,
matchup: matchup,
broadcasts: List.of(broadcast, broadcast),
location: location
});

it('should test formatted start date', function() {
let expected = '20170129';
expect(scoreboard.getNbaStatsFormattedStartDate()).to.equal(expected);
});

it('should test localized start date', function() {
let expected = 'January 30, 2017 12:00 AM';
expect(scoreboard.getLocalizedStartDateTime()).to.equal(expected);
});

it('should test tv broadcasts string', function() {
let expected = `${broadcastName},${broadcastName}`;
expect(scoreboard.getTvBroadcastsString()).to.eql(expected);
});
});

0 comments on commit 49f1f8b

Please sign in to comment.