action(value => { this.todos.push(value); })
add(todo) { this.todos.push(todo); }
function createStubDetailsStore(spans, promise, relatedTracesPromise = fulfilledPromise, relatedResults = []) { const store = new TraceDetailsStore(); sinon.stub(store, 'fetchTraceDetails', () => { store.spans = observable.array(spans); store.promiseState = promise; }); sinon.stub(store, 'fetchRelatedTraces', (query) => { store.relatedTraces = observable.array(relatedResults); store.relatedTracesPromiseState = relatedTracesPromise; store.searchQuery = query; }); return store; }
it('should trigger the correct function for the show all traces button', () => { // mocking window.open and the window object with focus method it returns const focusStub = sinon.stub(); global.window.open = () => ({ focus: focusStub }); const absStub = sinon.stub(linkBuilder, 'withAbsoluteUrl').returns('string'); const uniStub = sinon.stub(linkBuilder, 'universalSearchTracesLink').returns('string'); const wrapper = mount(<RelatedTracesTab searchQuery={{}} relatedTraces={observable.array(stubResults)} />); // Click showMoreTraces button wrapper.find('a.btn-primary').simulate('click'); expect(absStub.calledOnce).to.equal(true); expect(uniStub.calledOnce).to.equal(true); expect(focusStub.calledOnce).to.equal(true); linkBuilder.withAbsoluteUrl.restore(); linkBuilder.universalSearchTracesLink.restore(); delete global.window.open; });
describe('<DurationGraph />', () => { it('should not transform value as it is already in ms', () => { const from = 1000; const until = 2000; const xAxesTicks = { min: from, max: until }; const meanPoints = observable.array([{timestamp: 1530844500000, value: 902}]); const tp95Points = observable.array([]); const tp99Points = observable.array([]); const wrapper = shallow(<DurationGraph meanPoints={meanPoints} tp95Points={tp95Points} tp99Points={tp99Points} xAxesTicks={xAxesTicks} />); expect(wrapper.find(Line).props().data.datasets[2].data[0].y).to.equal(902); }); });
remove(todo) { this.todos.remove(this.getItemById(todo.id)); }
const wrapper = mount(<TagsTable tags={observable.array(stubDetails[0].tags)} />);
getItemById(id) { return this.todos.find(item => item.id === id); }