-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
57 additions
and
74 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,54 @@ | ||
import React from 'react' | ||
import assert from 'assert' | ||
import sinon from 'sinon' | ||
import ProjectMetadata from './metadata' | ||
import {shallow, render, mount} from 'enzyme' | ||
import React from 'react'; | ||
import assert from 'assert'; | ||
import sinon from 'sinon'; | ||
import { render, mount } from 'enzyme'; | ||
|
||
import ProjectMetadata from './metadata'; | ||
|
||
describe('ProjectMetadata', function(){ | ||
var project; | ||
var pusher; | ||
let project; | ||
let pusher; | ||
|
||
before(function() { | ||
project = {classifiers_count: 0, classifications_count: 0, subjects_count: 0, retired_subjects_count: 0}; | ||
project = { classifiers_count: 0, classifications_count: 0, completeness: 0.56, subjects_count: 0, retired_subjects_count: 0 }; | ||
|
||
const subscribe = function(channel) { return {bind: function(event, callback) { }}} | ||
pusher = {subscribe: subscribe}; | ||
const subscribe = function(channel) { return { bind: function(event, callback) { } }}; | ||
pusher = { subscribe }; | ||
}); | ||
|
||
it('renders stats', function(){ | ||
const context = {pusher: pusher}; | ||
const page = render(<ProjectMetadata project={project} />, {context}); | ||
assert(page.find('.project-metadata-stat').length, 4); | ||
}); | ||
describe('render', function() { | ||
let wrapper; | ||
before(function() { | ||
const context = { pusher }; | ||
wrapper = render(<ProjectMetadata project={project} />, { context }); | ||
}); | ||
|
||
it('subscribes to pusher', function() { | ||
const context = {pusher: pusher}; | ||
pusher.subscribe = sinon.spy(pusher.subscribe); | ||
const wrapper = mount(<ProjectMetadata project={project} />, {context}); | ||
wrapper.setContext(context); | ||
assert(pusher.subscribe.called, true); | ||
}); | ||
it('renders stats', function() { | ||
assert(wrapper.find('.project-metadata-stat').length, 4); | ||
}); | ||
|
||
it('subscribes to pusher', function() { | ||
const context = {pusher: pusher}; | ||
pusher.unsubscribe = sinon.spy(); | ||
|
||
const wrapper = mount(<ProjectMetadata project={project} />, {context}); | ||
wrapper.setContext(context); | ||
wrapper.unmount(); | ||
it('renders 56% completeness', function() { | ||
assert(wrapper.find('rect').first().prop('width'), 0.56); | ||
}); | ||
}); | ||
|
||
assert(pusher.unsubscribe.called, true); | ||
describe('pusher', function() { | ||
it('subscribes to pusher', function() { | ||
const context = { pusher }; | ||
pusher.subscribe = sinon.spy(pusher.subscribe); | ||
const wrapper = mount(<ProjectMetadata project={project} />, { context }); | ||
|
||
wrapper.setContext(context); | ||
assert(pusher.subscribe.called, true); | ||
}); | ||
|
||
it('unsubscribes to pusher', function() { | ||
pusher.unsubscribe = sinon.spy(); | ||
const context = { pusher }; | ||
const wrapper = mount(<ProjectMetadata project={project} />, { context }); | ||
wrapper.setContext(context); | ||
wrapper.unmount(); | ||
assert(pusher.unsubscribe.called, true); | ||
}); | ||
}); | ||
}); |