Skip to content

Instantly share code, notes, and snippets.

@jeffmo
Created May 15, 2014 01:17
Show Gist options
  • Save jeffmo/774236d5eee454e1f859 to your computer and use it in GitHub Desktop.
Save jeffmo/774236d5eee454e1f859 to your computer and use it in GitHub Desktop.
/** @jsx React.DOM */
jest.dontMock('../LanguageSelection');
jest.dontMock('../../store');
var React;
var TestUtils;
var LanguageSelection;
describe('LanguageSelection', function() {
beforeEach(function() {
React = require('react/addons');
TestUtils = React.addons.TestUtils;
LanguageSelection = require('../LanguageSelection');
});
it('should render <noscript> when there no available languages', function() {
var component = <LanguageSelection currentLocale="en"/>;
var languageSelection = TestUtils.renderIntoDocument(component);
var noscript = TestUtils.findRenderedDOMComponentWithTag(languageSelection, 'noscript');
expect(noscript).toBeTruthy();
});
it('should render select with options when languages are available', function() {
var LocaleStore = require('../../translations/LocaleStore');
LocaleStore.getAvailableLanguages.mockReturnValue([
['en', 'English'],
['de', 'German']
]);
var component = <LanguageSelection currentLocale="en"/>;
var languageSelection = TestUtils.renderIntoDocument(component);
//expect(LocaleStore.getAvailableLanguages.mock.calls.length).toBe(1);
//var options = TestUtils.scryRenderedDOMComponentsWithTag(languageSelection, 'option');
//expect(options.length).toEqual(2);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment