"use strict";

describe("Configuration", function() {
    var Configuration, $httpBackend;

    beforeEach(module("bibframeEditor"));
    beforeEach(inject(function($injector) {
        Configuration = $injector.get("Configuration");
        $httpBackend = $injector.get("$httpBackend");
        $httpBackend.whenGET("./config.json").respond({
            profiles: [
                "test"
            ],
            firstClass: [
                "urn:superclass"
            ],
            schemas: [
                "schema.n3"
            ],
            resourceMap: {},
            resourceDefinitions: {},
            services: {},
            dataTypes: {},
            idBase: ""
        });
        $httpBackend.whenGET("./profiles/test.json").respond({
            resourceTemplate: [
                {
                    id: "rt-test",
                    "class": {
                        id: "rt-class-test"
                    }
                }
            ]
        });
        $httpBackend.whenGET("./schema/schema.n3").respond("");
    }));
    /**
    it("should parse configuration", function() {
        // this might be basically un-testable - flush needs to be called
        // before Configuration.initialize is completed, and possibly scope
        // $digest, but there really isn't a way I know of how to get the
        // required fakery timed correctly.
        Configuration.initialize();
        $httpBackend.flush();
    });
    */
});

@@ -624,24 +624,66 @@
  services: %7B
+%0A                %22foo%22: %22bar%22%0A            
 %7D,%0A         
@@ -790,32 +790,59 @@
 son%22).respond(%7B%0A
+            Profile: %7B%0A    
             reso
@@ -873,16 +873,20 @@
         
+    
 %7B%0A      
@@ -891,32 +891,36 @@
                 
+ 
+   
 id: %22rt-test%22,%0A 
@@ -938,16 +938,20 @@
         
+   
+ 
 %22class%22:
@@ -949,24 +949,28 @@
  %22class%22: %7B%0A
+    
             
@@ -1013,34 +1013,41 @@
                 
-%7D%0A
+    %7D%0A   
                 
@@ -1038,32 +1038,33 @@
                 
+ 
 %7D%0A            %5D%0A
@@ -1061,17 +1061,35 @@
         
-%5D
+    %5D%0A            %7D
 %0A       
@@ -1153,17 +1153,147 @@
 espond(%22
-%22
+%3Crt-class-test%3E rdfs:subClassOf %3Curn:superclass%3E .%22);%0A        $httpBackend.whenPOST(%22../resource/id%22).respond(%5B%220%22,%221%22,%222%22,%223%22,%224%22%5D
 );%0A    %7D
@@ -1300,15 +1300,8 @@
 ));%0A
-    /**
 %0A   
@@ -1359,267 +1359,370 @@
     
-// this might be basically un-testable - flush needs to be called%0A        // before Configuration.initialize is completed, and possibly scope%0A        // $digest, but there really isn't a way I know of how to get the%0A        // required fakery timed correctly.
+Configuration.initialize();%0A        $httpBackend.flush();%0A        expect(Configuration.getConfig()).not.toBeNull();%0A        expect(Configuration.getFirstClass()).toEqual(%5B%22urn:superclass%22%5D);%0A        expect(Configuration.getSearchServices()).toEqual(%7Bfoo: %22bar%22%7D);%0A        //@@@ should be 1?%0A        //expect(Configuration.getResourceOptions().length).toEqual(0);
 %0A   
@@ -1718,32 +1718,39 @@
 ual(0);%0A        
+expect(
 Configuration.in
@@ -1740,32 +1740,34 @@
 (Configuration.i
+sI
 nitialize();%0A   
@@ -1763,39 +1763,25 @@
 lize
+d
 ()
-;%0A        $httpBackend.flush(
+).toEqual(true
 );%0A 
@@ -1791,14 +1791,8 @@
 %7D);%0A
-    */
 %0A%7D);

test stub for configuration, does seem to work with flush