mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-16 05:49:16 +02:00
added: first test (failing)
This commit is contained in:
@@ -158,7 +158,7 @@ function parseComments(comments) {
|
||||
}
|
||||
|
||||
var parsers = {
|
||||
note: function parseNote(obj, uid) {
|
||||
note: function parseNote(obj) {
|
||||
var attrs = obj.attributes;
|
||||
var childNodes = obj.childNodes;
|
||||
var parsedNote = {};
|
||||
|
||||
@@ -104,6 +104,7 @@
|
||||
|
||||
<script src='spec/services/mapillary.js'></script>
|
||||
<script src='spec/services/nominatim.js'></script>
|
||||
<script src='spec/services/notes.js'></script>
|
||||
<script src='spec/services/openstreetcam.js'></script>
|
||||
<script src='spec/services/osm.js'></script>
|
||||
<script src='spec/services/streetside.js'></script>
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
describe('iD.serviceNotes', function () {
|
||||
var dimensions = [64, 64],
|
||||
ua = navigator.userAgent,
|
||||
isPhantom = (navigator.userAgent.match(/PhantomJS/) !== null),
|
||||
uaMock = function () { return ua; },
|
||||
context, server, notes, orig;
|
||||
|
||||
|
||||
before(function() {
|
||||
iD.services.notes = iD.serviceNotes;
|
||||
});
|
||||
|
||||
after(function() {
|
||||
delete iD.services.notes;
|
||||
});
|
||||
|
||||
beforeEach(function() {
|
||||
context = iD.Context().assetPath('../dist/');
|
||||
context.projection
|
||||
.scale(667544.214430109) // z14
|
||||
.translate([-116508, 0]) // 10,0
|
||||
.clipExtent([[0,0], dimensions]);
|
||||
|
||||
server = sinon.fakeServer.create();
|
||||
notes = iD.services.notes;
|
||||
notes.reset();
|
||||
|
||||
/* eslint-disable no-global-assign */
|
||||
/* mock userAgent */
|
||||
if (isPhantom) {
|
||||
orig = navigator;
|
||||
navigator = Object.create(orig, { userAgent: { get: uaMock }});
|
||||
} else {
|
||||
orig = navigator.__lookupGetter__('userAgent');
|
||||
navigator.__defineGetter__('userAgent', uaMock);
|
||||
}
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
server.restore();
|
||||
|
||||
/* restore userAgent */
|
||||
if (isPhantom) {
|
||||
navigator = orig;
|
||||
} else {
|
||||
navigator.__defineGetter__('userAgent', orig);
|
||||
}
|
||||
/* eslint-enable no-global-assign */
|
||||
});
|
||||
|
||||
describe('#init', function () {
|
||||
it('Initializes cache one time', function () {
|
||||
var cache = notes.cache();
|
||||
expect(cache).to.have.property('notes');
|
||||
|
||||
notes.init();
|
||||
var cache2 = notes.cache();
|
||||
expect(cache).to.equal(cache2);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user