describe('Tooltip', () => { it('should render the tooltip', () => { const tooltip = mount(<Tooltip />) assert(tooltip.find(ReactTooltip).exists()) }) })
// Initializes the server and mounts it in the generated build directory. http.createServer((req, res) => { // If we are accessing the root, it should be redirected to the default language, // We shouldn't get a 404 page. if (req.url === '/') { req.url = `/${mainLocale}` } mount(req, res) }).listen(port, () => { console.log(`\x1B[32mServer running at http://localhost:${port}/${mainLocale}/\x1B[39m`) })
it('properly gives publicServerURL when set', done => { reconfigureServer({ publicServerURL: 'https://myserver.com/1' }).then( () => { const config = Config.get('test', 'http://localhost:8378/1'); expect(config.mount).toEqual('https://myserver.com/1'); done(); } ); });
window.si.fsSize().catch(() => { this.space_bar.text.innerHTML = "Could not calculate mountpoint usage."; this.space_bar.bar.value = 100; }).then(d => { d.forEach(fsBlock => { if (path.startsWith(fsBlock.mount)) { this.fsBlock = fsBlock; } }); this.renderDiskUsage(this.fsBlock); });
getFileLocation(config, filename) { return ( config.mount + '/files/' + config.applicationId + '/' + encodeURIComponent(filename) ); }
const mountWithIntl = (componentToMount, pluginTrads, context = {}) => { const intlProvider = new IntlProvider( { locale: 'en', messages: pluginTrads }, {} ); const { intl } = intlProvider.getChildContext(); return mount(React.cloneElement(componentToMount, { intl }), { context: { intl, ...context }, childContextTypes: { intl: intlShape, emitEvent: PropTypes.func }, }); }
describe('fetchMetricData', () => { it('should fetch Data', () => { const props = generateProps() props.settings.statusPageURL = undefined const graph = mount(<MetricsGraph {...props} />) const inst = graph.instance() inst.fetchMetricData(props.settings.statusPageURL, props.timeframe) assert(props.fetchData.callCount === getNumDates(props.timeframe) + 1) }) })
describe('componentDidMount', () => { it('should fetch MetricData if URL is available', () => { const props = generateProps() const graph = mount(<MetricsGraph {...props} />) const inst = graph.instance() // failed to change the method of MetricsGraph class. Change the method of instance instead. inst.fetchMetricData = sinon.spy() // call componentDidMount directly. The instance is re-created if unmount() and mount() are called. inst.componentDidMount() assert(inst.fetchMetricData.calledOnce) }) })
describe('AutolinkedText', () => { it('should linkify the text', () => { const text = 'github.com' const props = { text } const autolinkedText = mount(<AutolinkedText {...props} />) assert(autolinkedText.find({href: 'http://' + text}).length === 1) assert(autolinkedText.find('a').text() === text) }) })
const mountWithIntl = (componentToMount, pluginTrads, context = {}) => { const intlProvider = new IntlProvider( { locale: 'en', messages: pluginTrads }, {} ); const { intl } = intlProvider.getChildContext(); return mount(React.cloneElement(componentToMount, { intl }), { context: { intl, ...context }, childContextTypes: { intl: intlShape, emitEvent: PropTypes.func }, }); }
window.si.fsSize().catch(() => { this.space_bar.text.innerHTML = "Could not calculate mountpoint usage."; this.space_bar.bar.value = 100; }).then(d => { d.forEach(fsBlock => { if (path.startsWith(fsBlock.mount)) { this.fsBlock = fsBlock; } }); this.renderDiskUsage(this.fsBlock); });
describe('AutolinkedText', () => { it('should linkify the text', () => { const text = 'github.com' const props = { text } const autolinkedText = mount(<AutolinkedText {...props} />) assert(autolinkedText.find({href: 'http://' + text}).length === 1) assert(autolinkedText.find('a').text() === text) }) })
describe('fetchMetricData', () => { it('should fetch Data', () => { const props = generateProps() props.settings.statusPageURL = undefined const graph = mount(<MetricsGraph {...props} />) const inst = graph.instance() inst.fetchMetricData(props.settings.statusPageURL, props.timeframe) assert(props.fetchData.callCount === getNumDates(props.timeframe) + 1) }) })
it('properly removes trailing slash in mount', done => { reconfigureServer({}).then(() => { const config = Config.get('test', 'http://localhost:8378/1/'); expect(config.mount).toEqual('http://localhost:8378/1'); done(); }); });
describe('componentDidMount', () => { it('should fetch MetricData if URL is available', () => { const props = generateProps() const graph = mount(<MetricsGraph {...props} />) const inst = graph.instance() // failed to change the method of MetricsGraph class. Change the method of instance instead. inst.fetchMetricData = sinon.spy() // call componentDidMount directly. The instance is re-created if unmount() and mount() are called. inst.componentDidMount() assert(inst.fetchMetricData.calledOnce) }) })