Skip to content

Commit

Permalink
Add test for SymbolBucket#isEmpty being false if bucket has rtl text
Browse files Browse the repository at this point in the history
  • Loading branch information
Arindam Bose committed Dec 12, 2019
1 parent e01d087 commit 315742d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions test/unit/data/symbol_bucket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ test('SymbolBucket detects rtl text', (t) => {
t.end();
});

// Test to prevent symbol bucket with rtl from text being culled by worker serialization.
test('SymbolBucket with rtl text is NOT empty even though no symbol instances are created', (t) => {
const rtlBucket = bucketSetup('مرحبا');
const options = {iconDependencies: {}, glyphDependencies: {}};
rtlBucket.createArrays();
rtlBucket.populate([{feature}], options);

t.notOk(rtlBucket.isEmpty());
t.equal(rtlBucket.symbolInstances.length, 0);
t.end();
});

test('SymbolBucket detects rtl text mixed with ltr text', (t) => {
const mixedBucket = bucketSetup('مرحبا translates to hello');
const options = {iconDependencies: {}, glyphDependencies: {}};
Expand Down
4 changes: 3 additions & 1 deletion test/unit/source/tile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ test('expiring tiles', (t) => {
test('rtl text detection', (t) => {
t.test('Tile#hasRTLText is true when a tile loads a symbol bucket with rtl text', (t) => {
const tile = new Tile(new OverscaledTileID(1, 0, 1, 1, 1));
const symbolBucket = createSymbolBucket('test', 'Test', 'مرحبا', new CollisionBoxArray());
// Create a stub symbol bucket
const symbolBucket = createSymbolBucket('test', 'Test', 'test', new CollisionBoxArray());
// symbolBucket phasnt been populateed yet so we force override the value in the stub
symbolBucket.hasRTLText = true;
tile.loadVectorData(
createVectorData({rawTileData: createRawTileData(), buckets: [symbolBucket]}),
Expand Down

0 comments on commit 315742d

Please sign in to comment.