forked from mapbox/mapbox-gl-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request mapbox#2982 from mapbox/fix-add-source-type
Revise addSourceType to be independent of Map instance
- Loading branch information
Showing
7 changed files
with
215 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
var test = require('tap').test; | ||
var Source = require('../../../js/source/source'); | ||
|
||
test('Source', function (t) { | ||
t.test('#getCustomTypeNames', function (t) { | ||
t.same(Source.getCustomTypeNames(), []); | ||
Source.addType('source.test.type-1', function () {}); | ||
t.same(Source.getCustomTypeNames(), ['source.test.type-1']); | ||
t.end(); | ||
}); | ||
|
||
t.test('#addType', function (t) { | ||
function SourceType () {} | ||
Source.on('_add', onAdd); | ||
|
||
t.plan(2); | ||
Source.addType('source.test.type-2', SourceType); | ||
t.equal(Source.getType('source.test.type-2'), SourceType); | ||
function onAdd (event) { | ||
t.equal(event.name, 'source.test.type-2'); | ||
Source.off('_add', onAdd); | ||
} | ||
}); | ||
|
||
t.test('#addType throws for duplicate source type', function (t) { | ||
Source.addType('source.test.type-3', function () {}); | ||
t.throws(function () { | ||
Source.addType('source.test.type-3', function () {}); | ||
}); | ||
t.end(); | ||
}); | ||
|
||
t.end(); | ||
}); |
Oops, something went wrong.