forked from aguestuser/show-me-the-money
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from aepyornis/fix37
Fix the annotation visibility toggle
- Loading branch information
Showing
4 changed files
with
86 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
jest.unmock('../Annotation'); | ||
|
||
import Annotation from '../Annotation'; | ||
|
||
describe('Annotation', ()=>{ | ||
|
||
describe('defaults', ()=>{ | ||
it('returns an object', ()=> expect(typeof Annotation.defaults()).toEqual('object') ); | ||
}); | ||
|
||
describe('setDefaults', ()=> { | ||
|
||
it('provides defaults when given an empty object', () =>{ | ||
const a = Annotation.setDefaults({}); | ||
expect(a.header).toEqual("Untitled Annotation"); | ||
expect(a.text).toEqual(''); | ||
expect(a.nodeIds).toEqual([]); | ||
expect(a.captionIds).toEqual([]); | ||
expect(a.edgeIds).toEqual([]); | ||
expect(a.id).toBeDefined(); | ||
}); | ||
|
||
it('merges defaults when provided an annotation object', ()=>{ | ||
expect(Annotation.setDefaults({header: "new header"}).header).toEqual('new header'); | ||
expect(Annotation.setDefaults({header: "new header"}).nodeIds).toEqual([]); | ||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
jest.unmock("../annotations"); | ||
jest.unmock('../../actions'); | ||
jest.unmock("../../models/Annotation"); | ||
jest.unmock("lodash"); | ||
|
||
import reducer from "../annotations"; | ||
import {loadAnnotations, toggleAnnotations} from '../../actions'; | ||
|
||
describe("annotations reducer", ()=>{ | ||
|
||
it("should return initial state", () => { | ||
expect(reducer(undefined, {})).toEqual({list:[], visible: true, currentIndex: 0}); | ||
}); | ||
|
||
it('stores the annotations in state.list when LOAD_ANNOTATIONS is triggered', () =>{ | ||
let annotations = [{ | ||
id: '123', | ||
header: "header", | ||
text: "some text here", | ||
nodeIds: ["x1","33180","15957"], | ||
edgeIds: [], | ||
captionIds: [] | ||
}]; | ||
|
||
|
||
expect(reducer(undefined, loadAnnotations(annotations))).toEqual({ | ||
list: [{ | ||
id: '123', | ||
header: "header", | ||
text: "some text here", | ||
nodeIds: ["x1","33180","15957"], | ||
edgeIds: [], | ||
captionIds: [] | ||
}], | ||
visible: true, | ||
currentIndex: 0 | ||
}); | ||
|
||
}); | ||
|
||
describe('TOGGLE_ANNOTATIONS', ()=>{ | ||
|
||
it('flips the visible state from false to true', ()=>{ | ||
expect( reducer({visible: false}, toggleAnnotations({})) ).toEqual({visible: true}); | ||
}); | ||
|
||
it('flips the visible state from true to false', ()=>{ | ||
expect( reducer({visible: true}, toggleAnnotations({})) ).toEqual({visible: false}); | ||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters