Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions SpecRunner.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@
<html lang="en">
<head>
<title>Testing with Jasmine</title>

<!-- TimeExplorer dependencies -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0-alpha.4/handlebars.min.js"></script>
<script type="text/javascript" src="js/vis.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

<!-- jasmine -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.8.0/jasmine.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.8.0/jasmine.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.8.0/jasmine-html.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.8.0/boot.min.js"></script>

<!-- TimeExplorer -->
<script type="text/javascript" src="js/TimeExplorer.js"></script>
<script type="text/javascript" src="js/TimeExplorerSpec.js"></script>
</head>
Expand Down
52 changes: 48 additions & 4 deletions js/TimeExplorerSpec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
describe('Testing the functions of the TimeExplorer file', ()=>{
describe('Testing the functions of the TimeExplorer file', ()=> {

it('zip_arrays should zip two arrays of equal length', ()=>{
it('zip_arrays should zip two arrays of equal length', ()=> {
const arr1 = ["Joan", "Bill", "Bob"];
const arr2 = [1,2,3];
expect(zip_arrays(arr1,arr2)).toEqual({"Joan": 1, "Bill": 2, "Bob": 3});
})

it('timeParse should parse AM time', ()=>{
it('timeParse should parse AM time', ()=> {
const times = [
"10:20",
"10:20am",
Expand All @@ -16,7 +16,7 @@ describe('Testing the functions of the TimeExplorer file', ()=>{
times.forEach( time => expect(timeParse(time)).toEqual([10,20]));
})

it('timeParse should parse PM time', ()=>{
it('timeParse should parse PM time', ()=> {
const times = [
"10:20pm",
"10:20PM",
Expand Down Expand Up @@ -64,3 +64,47 @@ describe('Testing the functions of the TimeExplorer file', ()=>{
})

})

describe('Testing the TimeExplorer class', () => {
let div;
const api_key = "AIzaSyCA8GIsjw-QL-CC1v6fgDWmDyyhRM_ZESE";
const new_explorer = () => {
return new TimeExplorer(api_key);
}

beforeEach( ()=> {
div = document.createElement('div');
div.setAttribute("id", "timeline");
document.body.appendChild(div);
});

afterEach( ()=> {
div.remove();
div = null;
});

it('TimeExplorer should have options after initialization', ()=> {
explorer = new_explorer()
expect(explorer.options.timelineOptions.height).toEqual(window.innerHeight);
})

it('TimeExplorer.get_tag_col() should return "Tags"', ()=> {
explorer = new_explorer()
const tags = explorer.get_tag_col();
expect(tags).toEqual('Tags');
})

it('TimeExplorer.set_options() should extend options', ()=> {
explorer = new_explorer()
const r = explorer.set_options(["Joe"])
expect(r.timelineOptions['0']).toEqual("Joe");
})

it('TimeExplorer.slugify() should return a valid slug', ()=> {
explorer = new_explorer()
const slug = explorer.slugify("Let's make a slug");
expect(slug).toEqual("Let_s_make_a_slug");
})


})