Skip to content

how to test loading the current "map.layers.yaml" #22

@otsix

Description

@otsix

I want to do a simple test to check whether some layers are loaded correctly.
To do this, I need to use the configuration files placed on the folder "config" and wait for asynchronous calls.

I create a SpecMyLayers.js file on the "test/spec" folder like this:

describe('MyLayers tests', function() {

    XVM.CONFIGFILE = '../'+ XVM.CONFIGFILE;
    XVM.LAYERSFILE = '../'+ XVM.LAYERSFILE;
    XVM.CONTROLSFILE = '../'+ XVM.CONTROLSFILE;

    XVM.createDefaultMap();

    beforeEach(function() {        
        XVM.EventBus = new XVM.Event.EventBus();
    });

    var layer_list = {
        "RVG-1999" : false,
        "RVG-2004" : false,
        "RVG-2009" : false,
        "RVG" : false
    }

    for (var key in Object.keys(layer_list)){
        it('XVM has the layer: '+Object.keys(layer_list)[key], function() {

        runs(function () {
            layers = new XVM.Loader.Layers(XVM.Reader);
        });

        waitsFor(function(){
            return (XVM.map.OLLayers!=null);
            }, "XVM.map.OLLayers is not initialized", 5000);
        //NEVER  IS INITIALIZED            
        for (var i = 0; i < XVM.map.OLLayers.length; i++) {
            var layer_key = layer_list[key]; 
            if (XVM.map.OLLayers[i].name == layer_key ){
                layer_list[layer_key] = true;
            }
        };

        expect(layer_list[key]).toEqual(true);
      });            
    }
});

To run this I had to add this script on the "SpecRunner.html":

<script type="text/javascript" src="../src/XVMUtils.js"></script>

It looks that the layers never are loaded properly. What are i missing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions