mirror of
https://github.com/apache/superset.git
synced 2026-04-10 03:45:22 +00:00
Introducing a nice component as a label that show when data was loaded from cache, when the cache was taken (in humanize duration as in `a few minutes ago`) in a tooltip, and it can act as a button that can trigger a force-refresh. While working on it, it became clear that it was going to be hard to use this component in the Dashboard view since it's not pure React. I'm planning on refactoring the dashboard view with proper React/Redux and introducing the CachedLabel component at that point. While digging around in the Dashboard view I realized that there was a bunch on unused code around managing timers that was used in explorev1 and decided to rip it out.
27 lines
655 B
JavaScript
27 lines
655 B
JavaScript
import React from 'react';
|
|
import { expect } from 'chai';
|
|
import { describe, it } from 'mocha';
|
|
import { shallow } from 'enzyme';
|
|
import { Label } from 'react-bootstrap';
|
|
|
|
import CachedLabel from '../../../javascripts/components/CachedLabel';
|
|
|
|
describe('CachedLabel', () => {
|
|
const defaultProps = {
|
|
onClick: () => {},
|
|
cachedTimestamp: '2017-01-01',
|
|
};
|
|
|
|
it('is valid', () => {
|
|
expect(
|
|
React.isValidElement(<CachedLabel {...defaultProps} />),
|
|
).to.equal(true);
|
|
});
|
|
it('renders', () => {
|
|
const wrapper = shallow(
|
|
<CachedLabel {...defaultProps} />,
|
|
);
|
|
expect(wrapper.find(Label)).to.have.length(1);
|
|
});
|
|
});
|