Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommos0 committed Feb 1, 2019
1 parent a947597 commit 7cb509e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
40 changes: 21 additions & 19 deletions test/ProvenanceSlide.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ProvenanceSlide } from '../src/ProvenanceSlide';
import { SlideAnnotation } from '../src/SlideAnnotation';

const testNode1 = {
id: 'sdkljbgfoasdbfdsbvckjurebvlauwyb',
Expand Down Expand Up @@ -31,26 +32,26 @@ describe('single slide', () => {

expect(slide.name).toBe('test1');
expect(slide.duration).toBe(1);
expect(slide.delay).toBe(0);
expect(slide.transitionTime).toBe(0);
expect(slide.annotations).toEqual([]);
expect(slide.node).toEqual(null);
});

it('should make a slide with annotations and node set', () => {
const slide = new ProvenanceSlide('test2', 1, 0, ['haha'], testNode1);
const slide = new ProvenanceSlide('test2', 1, 0, [new SlideAnnotation('haha')], testNode1);
expect(slide).toBeInstanceOf(ProvenanceSlide);

expect(slide.name).toBe('test2');
expect(slide.duration).toBe(1);
expect(slide.delay).toBe(0);
expect(slide.annotations).toEqual(['haha']);
expect(slide.transitionTime).toBe(0);
expect(slide.annotations[0].data).toEqual('haha');
expect(slide.node).toEqual(testNode1);
});

describe('setters for private fields', () => {
let slide: ProvenanceSlide;
beforeEach(() => {
slide = new ProvenanceSlide('test1', 1, 0, ['haha'], testNode1);
slide = new ProvenanceSlide('test1', 1, 0, [new SlideAnnotation('haha')], testNode1);
});

it('has a name setter', () => {
Expand All @@ -66,9 +67,9 @@ describe('single slide', () => {
});

it('has a delay setter', () => {
expect(slide.delay).toBe(0);
slide.delay = 12;
expect(slide.delay).toBe(12);
expect(slide.transitionTime).toBe(0);
slide.transitionTime = 12;
expect(slide.transitionTime).toBe(12);
});

it('has a node setter', () => {
Expand All @@ -81,29 +82,30 @@ describe('single slide', () => {
describe('adding and removing annotations', () => {
let slide: ProvenanceSlide;
beforeEach(() => {
slide = new ProvenanceSlide('test1', 1, 0, ['haha'], testNode1);
slide = new ProvenanceSlide('test1', 1, 0, [new SlideAnnotation('haha')], testNode1);
});

describe('add annotations', () => {
it('can add an annotation', () => {
expect(slide.annotations[0]).toEqual('haha');
slide.addAnnotation('shiny!');
expect(slide.annotations[0]).toEqual('haha');
expect(slide.annotations[1]).toEqual('shiny!');
expect(slide.annotations[0].data).toEqual('haha');
slide.addAnnotation(new SlideAnnotation('shiny!'));
expect(slide.annotations[0].data).toEqual('haha');
expect(slide.annotations[1].data).toEqual('shiny!');
});
});

describe('can remove an annotation', () => {
beforeEach(() => {
slide.addAnnotation('shiny!');
slide.addAnnotation('awesome!');
slide.addAnnotation('insight!');
slide.addAnnotation(new SlideAnnotation('shiny!'));
slide.addAnnotation(new SlideAnnotation('awesome!'));
slide.addAnnotation(new SlideAnnotation('insight!'));
});

it('should remove the slide', () => {
expect(slide.annotations).toEqual(['haha', 'shiny!', 'awesome!', 'insight!']);
slide.removeAnnotation('awesome!');
expect(slide.annotations).toEqual(['haha', 'shiny!', 'insight!']);
expect(slide.annotations[0].data).toEqual('haha');
expect(slide.annotations[3].data).toEqual('insight!');
slide.removeAnnotation(slide.annotations[1]);
expect(slide.annotations[2].data).toEqual('insight!');
});
});
});
Expand Down
9 changes: 5 additions & 4 deletions test/ProvenanceSlideDeck.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ describe('ProvenanceTreeSlidedeck', () => {
tracker = new ProvenanceTracker(registry, graph, username);
traverser = new ProvenanceGraphTraverser(registry, graph);
slideDeck = new ProvenanceSlidedeck({ name: 'calculator', version: '1.0.0' }, traverser);
graph.addNode(testNode1);
});

it('should have a graph', () => {
Expand Down Expand Up @@ -218,7 +219,7 @@ describe('ProvenanceTreeSlidedeck', () => {
const spiedfunc = jest.spyOn(traverser, 'toStateNode');
slideDeck.selectedSlide = slideWithNode;
expect(slideWithNode.node).toBeDefined();
expect(spiedfunc).toHaveBeenCalledWith(slideWithNode.node.id);
expect(spiedfunc).toHaveBeenCalledWith(slideWithNode.node.id, 0);
});

it('will dispatch on slide selection', () => {
Expand Down Expand Up @@ -293,11 +294,11 @@ describe('ProvenanceTreeSlidedeck', () => {

describe('Time based indexing', () => {
beforeEach(() => {
slide1.delay = 0;
slide1.transitionTime = 0;
slide1.duration = 2;
slide2.delay = 10;
slide2.transitionTime = 10;
slide2.duration = 4;
slide3.delay = 20;
slide3.transitionTime = 20;
slide3.duration = 6;

slideDeck.addSlide(slide1);
Expand Down

0 comments on commit 7cb509e

Please sign in to comment.