Skip to content

Commit 35692f9

Browse files
committed
mv test to correct describe block
1 parent d78c4bf commit 35692f9

File tree

1 file changed

+104
-102
lines changed

1 file changed

+104
-102
lines changed

Diff for: test/jasmine/tests/bar_test.js

+104-102
Original file line numberDiff line numberDiff line change
@@ -1900,6 +1900,110 @@ describe('A bar plot', function() {
19001900
.catch(failTest)
19011901
.then(done);
19021902
});
1903+
1904+
it('should show/hide text in clipped and non-clipped layers', function(done) {
1905+
var fig = Lib.extendDeep({}, require('@mocks/bar_cliponaxis-false.json'));
1906+
gd = createGraphDiv();
1907+
1908+
// only show one bar trace
1909+
fig.data = [fig.data[0]];
1910+
1911+
// add a non-bar trace to make sure its module layer gets clipped
1912+
fig.data.push({
1913+
type: 'contour',
1914+
z: [[0, 0.5, 1], [0.5, 1, 3]]
1915+
});
1916+
1917+
function _assertClip(sel, exp, size, msg) {
1918+
if(exp === null) {
1919+
expect(sel.size()).toBe(0, msg + 'selection should not exist');
1920+
} else {
1921+
assertClip(sel, exp, size, msg);
1922+
}
1923+
}
1924+
1925+
function _assert(layerClips, barDisplays, barTextDisplays, barClips) {
1926+
var subplotLayer = d3.select('.plot');
1927+
var barLayer = subplotLayer.select('.barlayer');
1928+
1929+
_assertClip(subplotLayer, layerClips[0], 1, 'subplot layer');
1930+
_assertClip(subplotLayer.select('.contourlayer'), layerClips[1], 1, 'some other trace layer');
1931+
_assertClip(barLayer, layerClips[2], 1, 'bar layer');
1932+
1933+
assertNodeDisplay(
1934+
barLayer.selectAll('.point'),
1935+
barDisplays,
1936+
'bar points (never hidden by display attr)'
1937+
);
1938+
assertNodeDisplay(
1939+
barLayer.selectAll('.bartext'),
1940+
barTextDisplays,
1941+
'bar text'
1942+
);
1943+
1944+
assertClip(
1945+
barLayer.selectAll('.point > path'),
1946+
barClips[0], barClips[1],
1947+
'bar clips'
1948+
);
1949+
}
1950+
1951+
Plotly.newPlot(gd, fig).then(function() {
1952+
_assert(
1953+
[false, true, false],
1954+
[null, null, null],
1955+
[null, null, 'none'],
1956+
[true, 3]
1957+
);
1958+
return Plotly.restyle(gd, 'visible', false);
1959+
})
1960+
.then(function() {
1961+
_assert(
1962+
[true, null, null],
1963+
[],
1964+
[],
1965+
[false, 0]
1966+
);
1967+
return Plotly.restyle(gd, {visible: true, cliponaxis: null});
1968+
})
1969+
.then(function() {
1970+
_assert(
1971+
[true, false, false],
1972+
[null, null, null],
1973+
[null, null, null],
1974+
[false, 3]
1975+
);
1976+
return Plotly.restyle(gd, 'cliponaxis', false);
1977+
})
1978+
.then(function() {
1979+
_assert(
1980+
[false, true, false],
1981+
[null, null, null],
1982+
[null, null, 'none'],
1983+
[true, 3]
1984+
);
1985+
return Plotly.relayout(gd, 'yaxis.range', [0, 1]);
1986+
})
1987+
.then(function() {
1988+
_assert(
1989+
[false, true, false],
1990+
[null, null, null],
1991+
['none', 'none', 'none'],
1992+
[true, 3]
1993+
);
1994+
return Plotly.relayout(gd, 'yaxis.range', [0, 4]);
1995+
})
1996+
.then(function() {
1997+
_assert(
1998+
[false, true, false],
1999+
[null, null, null],
2000+
[null, null, null],
2001+
[true, 3]
2002+
);
2003+
})
2004+
.catch(failTest)
2005+
.then(done);
2006+
});
19032007
});
19042008

19052009
describe('bar visibility toggling:', function() {
@@ -2317,109 +2421,7 @@ describe('bar hover', function() {
23172421
});
23182422
});
23192423

2320-
it('should show/hide text in clipped and non-clipped layers', function(done) {
2321-
var fig = Lib.extendDeep({}, require('@mocks/bar_cliponaxis-false.json'));
2322-
gd = createGraphDiv();
2323-
2324-
// only show one bar trace
2325-
fig.data = [fig.data[0]];
2326-
2327-
// add a non-bar trace to make sure its module layer gets clipped
2328-
fig.data.push({
2329-
type: 'contour',
2330-
z: [[0, 0.5, 1], [0.5, 1, 3]]
2331-
});
2332-
2333-
function _assertClip(sel, exp, size, msg) {
2334-
if(exp === null) {
2335-
expect(sel.size()).toBe(0, msg + 'selection should not exist');
2336-
} else {
2337-
assertClip(sel, exp, size, msg);
2338-
}
2339-
}
2340-
2341-
function _assert(layerClips, barDisplays, barTextDisplays, barClips) {
2342-
var subplotLayer = d3.select('.plot');
2343-
var barLayer = subplotLayer.select('.barlayer');
2344-
2345-
_assertClip(subplotLayer, layerClips[0], 1, 'subplot layer');
2346-
_assertClip(subplotLayer.select('.contourlayer'), layerClips[1], 1, 'some other trace layer');
2347-
_assertClip(barLayer, layerClips[2], 1, 'bar layer');
2348-
2349-
assertNodeDisplay(
2350-
barLayer.selectAll('.point'),
2351-
barDisplays,
2352-
'bar points (never hidden by display attr)'
2353-
);
2354-
assertNodeDisplay(
2355-
barLayer.selectAll('.bartext'),
2356-
barTextDisplays,
2357-
'bar text'
2358-
);
23592424

2360-
assertClip(
2361-
barLayer.selectAll('.point > path'),
2362-
barClips[0], barClips[1],
2363-
'bar clips'
2364-
);
2365-
}
2366-
2367-
Plotly.newPlot(gd, fig).then(function() {
2368-
_assert(
2369-
[false, true, false],
2370-
[null, null, null],
2371-
[null, null, 'none'],
2372-
[true, 3]
2373-
);
2374-
return Plotly.restyle(gd, 'visible', false);
2375-
})
2376-
.then(function() {
2377-
_assert(
2378-
[true, null, null],
2379-
[],
2380-
[],
2381-
[false, 0]
2382-
);
2383-
return Plotly.restyle(gd, {visible: true, cliponaxis: null});
2384-
})
2385-
.then(function() {
2386-
_assert(
2387-
[true, false, false],
2388-
[null, null, null],
2389-
[null, null, null],
2390-
[false, 3]
2391-
);
2392-
return Plotly.restyle(gd, 'cliponaxis', false);
2393-
})
2394-
.then(function() {
2395-
_assert(
2396-
[false, true, false],
2397-
[null, null, null],
2398-
[null, null, 'none'],
2399-
[true, 3]
2400-
);
2401-
return Plotly.relayout(gd, 'yaxis.range', [0, 1]);
2402-
})
2403-
.then(function() {
2404-
_assert(
2405-
[false, true, false],
2406-
[null, null, null],
2407-
['none', 'none', 'none'],
2408-
[true, 3]
2409-
);
2410-
return Plotly.relayout(gd, 'yaxis.range', [0, 4]);
2411-
})
2412-
.then(function() {
2413-
_assert(
2414-
[false, true, false],
2415-
[null, null, null],
2416-
[null, null, null],
2417-
[true, 3]
2418-
);
2419-
})
2420-
.catch(failTest)
2421-
.then(done);
2422-
});
24232425
});
24242426

24252427
describe('event data', function() {

0 commit comments

Comments
 (0)