-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding more specs to the admin site * Adding the sidebar spec * Fixing some of the hound errors * Fixing more hound errors * Need to find a linter to help with this hound stuff * Finishing off the problems
- Loading branch information
Showing
9 changed files
with
648 additions
and
0 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,50 @@ | ||
import React from 'react'; | ||
import TestUtils from 'react-addons-test-utils'; | ||
import { Provider } from 'react-redux'; | ||
import _ from 'lodash'; | ||
import Helper from '../../../../specs_support/helper'; | ||
import Heading from './heading'; | ||
|
||
describe('common heading', () => { | ||
let result; | ||
let back = false; | ||
|
||
const props = { | ||
back: () => { back = true; }, | ||
}; | ||
|
||
beforeEach(() => { | ||
result = TestUtils.renderIntoDocument( | ||
<Provider store={Helper.makeStore()}> | ||
<Heading {...props} /> | ||
</Provider> | ||
); | ||
}); | ||
|
||
it('renders', () => { | ||
expect(result).toBeDefined(); | ||
}); | ||
|
||
it('renders the form not null', () => { | ||
expect(result).not.toBeNull(); | ||
}); | ||
|
||
describe('back button', () => { | ||
it('closes', () => { | ||
const buttons = TestUtils.scryRenderedDOMComponentsWithTag(result, 'button'); | ||
const backButton = _.find(buttons, { textContent: 'Back' }); | ||
expect(backButton).toBeDefined(); | ||
TestUtils.Simulate.click(backButton); | ||
expect(back).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('dropdown button', () => { | ||
it('has a presence', () => { | ||
const button = TestUtils.findRenderedDOMComponentWithClass(result, 'c-username'); | ||
expect(button.children[0].textContent).toBe(''); | ||
expect(button.children[1].className).toBe('i-dropdown'); | ||
}); | ||
}); | ||
|
||
}); |
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,46 @@ | ||
import React from 'react'; | ||
import TestUtils from 'react-addons-test-utils'; | ||
import Stub from '../../../../specs_support/stub'; | ||
import Search from './search'; | ||
|
||
describe('common search', () => { | ||
|
||
let result; | ||
let search = ''; | ||
|
||
const props = { | ||
search: (value) => { search = value; }, | ||
}; | ||
|
||
beforeEach(() => { | ||
result = TestUtils.renderIntoDocument( | ||
<Stub> | ||
<Search {...props} /> | ||
</Stub> | ||
); | ||
}); | ||
|
||
it('renders', () => { | ||
expect(result).toBeDefined(); | ||
}); | ||
|
||
it('renders the form not null', () => { | ||
expect(result).not.toBeNull(); | ||
}); | ||
|
||
it('has search input', () => { | ||
const input = TestUtils.findRenderedDOMComponentWithTag(result, 'input'); | ||
expect(input).toBeDefined(); | ||
expect(input.type).toBe('text'); | ||
expect(input.placeholder).toBe('Search...'); | ||
}); | ||
|
||
it('search input changes', () => { | ||
const input = TestUtils.findRenderedDOMComponentWithTag(result, 'input'); | ||
const newValue = '27'; | ||
input.value = newValue; | ||
TestUtils.Simulate.change(input); | ||
expect(input.value).toBe(search); | ||
}); | ||
|
||
}); |
59 changes: 59 additions & 0 deletions
59
client/js/_admin/components/common/settings_inputs.spec.jsx
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,59 @@ | ||
import React from 'react'; | ||
import TestUtils from 'react-addons-test-utils'; | ||
import _ from 'lodash'; | ||
import Stub from '../../../../specs_support/stub'; | ||
import SettingsInputs from './settings_inputs'; | ||
|
||
describe('common search inputs', () => { | ||
let result; | ||
const ltiKey = 'lti_key'; | ||
const ltiName = 'ltiName'; | ||
|
||
const props = { | ||
settings: { | ||
lti_key: ltiKey, | ||
name: ltiName, | ||
}, | ||
}; | ||
|
||
beforeEach(() => { | ||
result = TestUtils.renderIntoDocument( | ||
<Stub> | ||
<SettingsInputs {...props} /> | ||
</Stub> | ||
); | ||
}); | ||
|
||
it('renders', () => { | ||
expect(result).toBeDefined(); | ||
}); | ||
|
||
it('renders the form not null', () => { | ||
expect(result).not.toBeNull(); | ||
}); | ||
|
||
it('has hidden input', () => { | ||
const inputs = TestUtils.scryRenderedDOMComponentsWithTag(result, 'input'); | ||
const input = _.find(inputs, { name: 'oauth_consumer_key' }); | ||
expect(input).toBeDefined(); | ||
expect(input.type).toBe('hidden'); | ||
expect(input.value).toBe(ltiKey); | ||
}); | ||
|
||
it('search input changes', () => { | ||
const inputs = TestUtils.scryRenderedDOMComponentsWithTag(result, 'input'); | ||
const input = _.find(inputs, { name: 'lti_key' }); | ||
expect(input).toBeDefined(); | ||
expect(input.type).toBe('hidden'); | ||
expect(input.value).toBe(ltiKey); | ||
}); | ||
|
||
it('search input changes', () => { | ||
const inputs = TestUtils.scryRenderedDOMComponentsWithTag(result, 'input'); | ||
const input = _.find(inputs, { name: 'name' }); | ||
expect(input).toBeDefined(); | ||
expect(input.type).toBe('hidden'); | ||
expect(input.value).toBe(ltiName); | ||
}); | ||
|
||
}); |
90 changes: 90 additions & 0 deletions
90
client/js/_admin/components/lti_installs/account_install.spec.jsx
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,90 @@ | ||
import React from 'react'; | ||
import TestUtils from 'react-addons-test-utils'; | ||
import { Provider } from 'react-redux'; | ||
import Helper from '../../../../specs_support/helper'; | ||
import AccountInstall from './account_install'; | ||
|
||
describe('lti installs account install', () => { | ||
|
||
let result; | ||
const accountInstalls = 123; | ||
const accountName = 'accountName'; | ||
|
||
describe('with account present', () => { | ||
beforeEach(() => { | ||
const account = { | ||
id: 12, | ||
name: accountName, | ||
external_tools: { | ||
consumer_key: 'consumer_key' | ||
} | ||
}; | ||
|
||
const props = { | ||
applicationInstance: { | ||
lti_key: 'lti_key' | ||
}, | ||
canvasRequest: () => {}, | ||
accountInstalls, | ||
account, | ||
}; | ||
|
||
result = TestUtils.renderIntoDocument( | ||
<Provider store={Helper.makeStore()}> | ||
<AccountInstall {...props} /> | ||
</Provider> | ||
); | ||
}); | ||
|
||
it('renders', () => { | ||
expect(result).toBeDefined(); | ||
}); | ||
|
||
it('renders the form not null', () => { | ||
expect(result).not.toBeNull(); | ||
}); | ||
|
||
it('renders a header', () => { | ||
const h1 = TestUtils.findRenderedDOMComponentWithTag(result, 'h1'); | ||
expect(h1.textContent).toBe('123'); | ||
}); | ||
|
||
it('renders a header h3', () => { | ||
const h3 = TestUtils.findRenderedDOMComponentWithTag(result, 'h3'); | ||
expect(h3.textContent).toBe(accountName); | ||
}); | ||
|
||
it('renders buttons', () => { | ||
const accountButton = TestUtils.findRenderedDOMComponentWithTag(result, 'button'); | ||
expect(accountButton.textContent).toBe(`Install into ${accountName}`); | ||
}); | ||
}); | ||
|
||
describe('with account present', () => { | ||
beforeEach(() => { | ||
const props = { | ||
applicationInstance: { | ||
lti_key: 'lti_key' | ||
}, | ||
canvasRequest: () => {}, | ||
accountInstalls, | ||
}; | ||
|
||
result = TestUtils.renderIntoDocument( | ||
<Provider store={Helper.makeStore()}> | ||
<AccountInstall {...props} /> | ||
</Provider> | ||
); | ||
}); | ||
|
||
it('renders a header h3', () => { | ||
const h3 = TestUtils.findRenderedDOMComponentWithTag(result, 'h3'); | ||
expect(h3.textContent).toBe('Root'); | ||
}); | ||
|
||
it('renders buttons', () => { | ||
const accountButton = TestUtils.findRenderedDOMComponentWithTag(result, 'button'); | ||
expect(accountButton.textContent).toBe('Install into Root'); | ||
}); | ||
}); | ||
}); |
56 changes: 56 additions & 0 deletions
56
client/js/_admin/components/lti_installs/course_install_row.spec.jsx
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,56 @@ | ||
import React from 'react'; | ||
import TestUtils from 'react-addons-test-utils'; | ||
import { Provider } from 'react-redux'; | ||
import Helper from '../../../../specs_support/helper'; | ||
import CourseInstallRow from './course_install_row'; | ||
|
||
describe('lti installs course install row', () => { | ||
|
||
let result; | ||
const courseId = 123; | ||
const courseName = 'courseName'; | ||
|
||
const props = { | ||
applicationInstance: { | ||
name: 'application_name', | ||
lti_key: 'lti_key', | ||
lti_secret: 'lti_secret', | ||
lti_config_xml: 'lti_config_xml', | ||
}, | ||
installedTool: { | ||
id: 12 | ||
}, | ||
canvasRequest: () => {}, | ||
courseName, | ||
courseId, | ||
}; | ||
|
||
beforeEach(() => { | ||
result = TestUtils.renderIntoDocument( | ||
<Provider store={Helper.makeStore()}> | ||
<table><tbody> | ||
<CourseInstallRow {...props} /> | ||
</tbody></table> | ||
</Provider> | ||
); | ||
}); | ||
|
||
it('renders', () => { | ||
expect(result).toBeDefined(); | ||
}); | ||
|
||
it('renders the form not null', () => { | ||
expect(result).not.toBeNull(); | ||
}); | ||
|
||
it('renders row', () => { | ||
const courseTitle = TestUtils.findRenderedDOMComponentWithClass(result, 'c-table--inactive'); | ||
expect(courseTitle.textContent).toBe(courseName); | ||
}); | ||
|
||
it('renders buttons', () => { | ||
const installButton = TestUtils.findRenderedDOMComponentWithTag(result, 'button'); | ||
expect(installButton.textContent).toBe('Uninstall'); | ||
}); | ||
|
||
}); |
53 changes: 53 additions & 0 deletions
53
client/js/_admin/components/lti_installs/course_installs.spec.jsx
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 @@ | ||
import React from 'react'; | ||
import TestUtils from 'react-addons-test-utils'; | ||
import { Provider } from 'react-redux'; | ||
import Helper from '../../../../specs_support/helper'; | ||
import CourseInstalls from './course_installs'; | ||
|
||
describe('lti installs course install', () => { | ||
|
||
let result; | ||
const courseId = 123; | ||
|
||
const props = { | ||
applicationInstance: { | ||
name: 'application_name', | ||
lti_key: 'lti_key', | ||
lti_secret: 'lti_secret', | ||
lti_config_xml: 'lti_config_xml', | ||
}, | ||
canvasRequest: () => {}, | ||
loadingCourses: { | ||
courseName: 'name', | ||
courseId: 'id', | ||
}, | ||
courses: [], | ||
installedTool: { | ||
id: 12 | ||
}, | ||
courseName: 'courseName', | ||
courseId, | ||
}; | ||
|
||
beforeEach(() => { | ||
result = TestUtils.renderIntoDocument( | ||
<Provider store={Helper.makeStore()}> | ||
<CourseInstalls {...props} /> | ||
</Provider> | ||
); | ||
}); | ||
|
||
it('renders', () => { | ||
expect(result).toBeDefined(); | ||
}); | ||
|
||
it('renders the form not null', () => { | ||
expect(result).not.toBeNull(); | ||
}); | ||
|
||
it('renders buttons', () => { | ||
const courseName = TestUtils.findRenderedDOMComponentWithTag(result, 'span'); | ||
expect(courseName.textContent).toBe('Course Name'); | ||
}); | ||
|
||
}); |
Oops, something went wrong.