<NME> style_test.js
<BEF> // Copyright 2014 Google Inc. All rights reserved.
//
// Use of this source code is governed by The MIT License.
// See the LICENSE file for details.

/**
 * @fileoverview Tests for dynamically loading styles.
 */

goog.require('spf.array');
goog.require('spf.net.resource');
goog.require('spf.net.style');


describe('spf.net.style', function() {

  var css = spf.net.resource.Type.CSS;

  beforeEach(function() {
    spyOn(spf.net.resource, 'load');
    spyOn(spf.net.resource, 'unload');
    spyOn(spf.net.resource, 'create');
    spyOn(spf.net.resource, 'prefetch');
  });


  describe('load', function() {

    it('passes a single url with name', function() {
      var url = 'url-a.css';
      var name = 'a';
      spf.net.style.load(url, name);
      expect(spf.net.resource.load).toHaveBeenCalledWith(
          css, url, name, undefined);
    });

    it('passes a single url with name and callback', function() {
      var url = 'url-a.css';
      var name = 'a';
      var fn = function() {};
      spf.net.style.load(url, name, fn);
      expect(spf.net.resource.load).toHaveBeenCalledWith(
          css, url, name, fn);
    });

    it('passes multiple urls with name', function() {
      var urls = ['url-a-1.css', 'url-a-2.css'];
      var name = 'a';
      spf.net.style.load(urls, name);
      expect(spf.net.resource.load).toHaveBeenCalledWith(
          css, urls, name, undefined);
    });

    it('passes multiple urls with name and callback', function() {
    });
      var name = 'a';
      var fn = function() {};
      spf.net.style.load(urls, name, fn);
      expect(spf.net.resource.load).toHaveBeenCalledWith(
          css, urls, name, fn);
    });

  });
      var url = 'url-a.css';
      var fn = undefined;
      spf.net.style.get(url);
      expect(spf.net.resource.create).toHaveBeenCalledWith(CSS, url, fn);
    it('passes name', function() {
      var name = 'a';
      spf.net.style.unload(name);
      expect(spf.net.resource.unload).toHaveBeenCalledWith(css, name);
    });

  });
    });

  });

    it('passes url', function() {
      var url = 'url-a.css';
      spf.net.style.get(url);
      expect(spf.net.resource.create).toHaveBeenCalledWith(
          css, url, undefined);
    });

    it('passes url with function', function() {
      var url = 'url-a.css';
      var fn = function() {};
      spf.net.style.get(url, fn);
      expect(spf.net.resource.create).toHaveBeenCalledWith(
          css, url, fn);
    });

  });
    });

  });

    it('calls for a single url', function() {
      var url = 'url-a.css';
      spf.net.style.prefetch(url);
      expect(spf.net.resource.prefetch).toHaveBeenCalledWith(
          css, url);
    });

    it('calls for multiples urls', function() {
      var urls = ['url-a-1.css', 'url-a-2.css'];
      spf.net.style.prefetch(urls);
      spf.array.each(urls, function(url) {
        expect(spf.net.resource.prefetch).toHaveBeenCalledWith(
            css, url);
      });
    });


<MSG> Merge pull request #150 from nicksay/resource-loading-streamline-tests

Cleanup spf.net.script and spf.net.style tests.
<DFF> @@ -14,7 +14,7 @@ goog.require('spf.net.style');
 
 describe('spf.net.style', function() {
 
-  var css = spf.net.resource.Type.CSS;
+  var CSS = spf.net.resource.Type.CSS;
 
   beforeEach(function() {
     spyOn(spf.net.resource, 'load');
@@ -29,9 +29,9 @@ describe('spf.net.style', function() {
     it('passes a single url with name', function() {
       var url = 'url-a.css';
       var name = 'a';
+      var fn = undefined;
       spf.net.style.load(url, name);
-      expect(spf.net.resource.load).toHaveBeenCalledWith(
-          css, url, name, undefined);
+      expect(spf.net.resource.load).toHaveBeenCalledWith(CSS, url, name, fn);
     });
 
     it('passes a single url with name and callback', function() {
@@ -39,16 +39,15 @@ describe('spf.net.style', function() {
       var name = 'a';
       var fn = function() {};
       spf.net.style.load(url, name, fn);
-      expect(spf.net.resource.load).toHaveBeenCalledWith(
-          css, url, name, fn);
+      expect(spf.net.resource.load).toHaveBeenCalledWith(CSS, url, name, fn);
     });
 
     it('passes multiple urls with name', function() {
       var urls = ['url-a-1.css', 'url-a-2.css'];
       var name = 'a';
+      var fn = undefined;
       spf.net.style.load(urls, name);
-      expect(spf.net.resource.load).toHaveBeenCalledWith(
-          css, urls, name, undefined);
+      expect(spf.net.resource.load).toHaveBeenCalledWith(CSS, urls, name, fn);
     });
 
     it('passes multiple urls with name and callback', function() {
@@ -56,8 +55,7 @@ describe('spf.net.style', function() {
       var name = 'a';
       var fn = function() {};
       spf.net.style.load(urls, name, fn);
-      expect(spf.net.resource.load).toHaveBeenCalledWith(
-          css, urls, name, fn);
+      expect(spf.net.resource.load).toHaveBeenCalledWith(CSS, urls, name, fn);
     });
 
   });
@@ -68,7 +66,7 @@ describe('spf.net.style', function() {
     it('passes name', function() {
       var name = 'a';
       spf.net.style.unload(name);
-      expect(spf.net.resource.unload).toHaveBeenCalledWith(css, name);
+      expect(spf.net.resource.unload).toHaveBeenCalledWith(CSS, name);
     });
 
   });
@@ -78,17 +76,16 @@ describe('spf.net.style', function() {
 
     it('passes url', function() {
       var url = 'url-a.css';
+      var fn = undefined;
       spf.net.style.get(url);
-      expect(spf.net.resource.create).toHaveBeenCalledWith(
-          css, url, undefined);
+      expect(spf.net.resource.create).toHaveBeenCalledWith(CSS, url, fn);
     });
 
     it('passes url with function', function() {
       var url = 'url-a.css';
       var fn = function() {};
       spf.net.style.get(url, fn);
-      expect(spf.net.resource.create).toHaveBeenCalledWith(
-          css, url, fn);
+      expect(spf.net.resource.create).toHaveBeenCalledWith(CSS, url, fn);
     });
 
   });
@@ -99,16 +96,14 @@ describe('spf.net.style', function() {
     it('calls for a single url', function() {
       var url = 'url-a.css';
       spf.net.style.prefetch(url);
-      expect(spf.net.resource.prefetch).toHaveBeenCalledWith(
-          css, url);
+      expect(spf.net.resource.prefetch).toHaveBeenCalledWith(CSS, url);
     });
 
     it('calls for multiples urls', function() {
       var urls = ['url-a-1.css', 'url-a-2.css'];
       spf.net.style.prefetch(urls);
       spf.array.each(urls, function(url) {
-        expect(spf.net.resource.prefetch).toHaveBeenCalledWith(
-            css, url);
+        expect(spf.net.resource.prefetch).toHaveBeenCalledWith(CSS, url);
       });
     });
 

{'commit': "diff --git a/src/client/net/script_test.js b/src/client/net/script_test.js\nindex 9ccf2b8..1d8733d 100644\n--- a/src/client/net/script_test.js\n+++ b/src/client/net/script_test.js\n@@ -106,9 +106,9 @@ describe('spf.net.script', function() {\n     it('passes a single url with name', function() {\n       var url = 'url-a.js';\n       var name = 'a';\n+      var fn = undefined;\n       spf.net.script.load(url, name);\n-      expect(spf.net.resource.load).toHaveBeenCalledWith(\n-          JS, url, name, undefined);\n+      expect(spf.net.resource.load).toHaveBeenCalledWith(JS, url, name, fn);\n     });\n \n     it('passes a single url with name and callback', function() {\n@@ -116,16 +116,15 @@ describe('spf.net.script', function() {\n       var name = 'a';\n       var fn = function() {};\n       spf.net.script.load(url, name, fn);\n-      expect(spf.net.resource.load).toHaveBeenCalledWith(\n-          JS, url, name, fn);\n+      expect(spf.net.resource.load).toHaveBeenCalledWith(JS, url, name, fn);\n     });\n \n     it('passes multiple urls with name', function() {\n       var urls = ['url-a-1.js', 'url-a-2.js'];\n       var name = 'a';\n+      var fn = undefined;\n       spf.net.script.load(urls, name);\n-      expect(spf.net.resource.load).toHaveBeenCalledWith(\n-          JS, urls, name, undefined);\n+      expect(spf.net.resource.load).toHaveBeenCalledWith(JS, urls, name, fn);\n     });\n \n     it('passes multiple urls with name and callback', function() {\n@@ -133,8 +132,7 @@ describe('spf.net.script', function() {\n       var name = 'a';\n       var fn = function() {};\n       spf.net.script.load(urls, name, fn);\n-      expect(spf.net.resource.load).toHaveBeenCalledWith(\n-          JS, urls, name, fn);\n+      expect(spf.net.resource.load).toHaveBeenCalledWith(JS, urls, name, fn);\n     });\n \n   });\n@@ -156,16 +154,15 @@ describe('spf.net.script', function() {\n     it('passes url', function() {\n       var url = 'url-a.js';\n       spf.net.script.get(url);\n-      expect(spf.net.resource.create).toHaveBeenCalledWith(\n-          JS, url, undefined);\n+      var fn = undefined;\n+      expect(spf.net.resource.create).toHaveBeenCalledWith(JS, url, fn);\n     });\n \n     it('passes url with function', function() {\n       var url = 'url-a.js';\n       var fn = function() {};\n       spf.net.script.get(url, fn);\n-      expect(spf.net.resource.create).toHaveBeenCalledWith(\n-          JS, url, fn);\n+      expect(spf.net.resource.create).toHaveBeenCalledWith(JS, url, fn);\n     });\n \n   });\n@@ -176,16 +173,14 @@ describe('spf.net.script', function() {\n     it('calls for a single url', function() {\n       var url = 'url-a.js';\n       spf.net.script.prefetch(url);\n-      expect(spf.net.resource.prefetch).toHaveBeenCalledWith(\n-          JS, url);\n+      expect(spf.net.resource.prefetch).toHaveBeenCalledWith(JS, url);\n     });\n \n     it('calls for multiples urls', function() {\n       var urls = ['url-a-1.js', 'url-a-2.js'];\n       spf.net.script.prefetch(urls);\n       spf.array.each(urls, function(url) {\n-        expect(spf.net.resource.prefetch).toHaveBeenCalledWith(\n-            JS, url);\n+        expect(spf.net.resource.prefetch).toHaveBeenCalledWith(JS, url);\n       });\n     });\n \ndiff --git a/src/client/net/style_test.js b/src/client/net/style_test.js\nindex 6eb5902..6ba0618 100644\n--- a/src/client/net/style_test.js\n+++ b/src/client/net/style_test.js\n@@ -14,7 +14,7 @@ goog.require('spf.net.style');\n \n describe('spf.net.style', function() {\n \n-  var css = spf.net.resource.Type.CSS;\n+  var CSS = spf.net.resource.Type.CSS;\n \n   beforeEach(function() {\n     spyOn(spf.net.resource, 'load');\n@@ -29,9 +29,9 @@ describe('spf.net.style', function() {\n     it('passes a single url with name', function() {\n       var url = 'url-a.css';\n       var name = 'a';\n+      var fn = undefined;\n       spf.net.style.load(url, name);\n-      expect(spf.net.resource.load).toHaveBeenCalledWith(\n-          css, url, name, undefined);\n+      expect(spf.net.resource.load).toHaveBeenCalledWith(CSS, url, name, fn);\n     });\n \n     it('passes a single url with name and callback', function() {\n@@ -39,16 +39,15 @@ describe('spf.net.style', function() {\n       var name = 'a';\n       var fn = function() {};\n       spf.net.style.load(url, name, fn);\n-      expect(spf.net.resource.load).toHaveBeenCalledWith(\n-          css, url, name, fn);\n+      expect(spf.net.resource.load).toHaveBeenCalledWith(CSS, url, name, fn);\n     });\n \n     it('passes multiple urls with name', function() {\n       var urls = ['url-a-1.css', 'url-a-2.css'];\n       var name = 'a';\n+      var fn = undefined;\n       spf.net.style.load(urls, name);\n-      expect(spf.net.resource.load).toHaveBeenCalledWith(\n-          css, urls, name, undefined);\n+      expect(spf.net.resource.load).toHaveBeenCalledWith(CSS, urls, name, fn);\n     });\n \n     it('passes multiple urls with name and callback', function() {\n@@ -56,8 +55,7 @@ describe('spf.net.style', function() {\n       var name = 'a';\n       var fn = function() {};\n       spf.net.style.load(urls, name, fn);\n-      expect(spf.net.resource.load).toHaveBeenCalledWith(\n-          css, urls, name, fn);\n+      expect(spf.net.resource.load).toHaveBeenCalledWith(CSS, urls, name, fn);\n     });\n \n   });\n@@ -68,7 +66,7 @@ describe('spf.net.style', function() {\n     it('passes name', function() {\n       var name = 'a';\n       spf.net.style.unload(name);\n-      expect(spf.net.resource.unload).toHaveBeenCalledWith(css, name);\n+      expect(spf.net.resource.unload).toHaveBeenCalledWith(CSS, name);\n     });\n \n   });\n@@ -78,17 +76,16 @@ describe('spf.net.style', function() {\n \n     it('passes url', function() {\n       var url = 'url-a.css';\n+      var fn = undefined;\n       spf.net.style.get(url);\n-      expect(spf.net.resource.create).toHaveBeenCalledWith(\n-          css, url, undefined);\n+      expect(spf.net.resource.create).toHaveBeenCalledWith(CSS, url, fn);\n     });\n \n     it('passes url with function', function() {\n       var url = 'url-a.css';\n       var fn = function() {};\n       spf.net.style.get(url, fn);\n-      expect(spf.net.resource.create).toHaveBeenCalledWith(\n-          css, url, fn);\n+      expect(spf.net.resource.create).toHaveBeenCalledWith(CSS, url, fn);\n     });\n \n   });\n@@ -99,16 +96,14 @@ describe('spf.net.style', function() {\n     it('calls for a single url', function() {\n       var url = 'url-a.css';\n       spf.net.style.prefetch(url);\n-      expect(spf.net.resource.prefetch).toHaveBeenCalledWith(\n-          css, url);\n+      expect(spf.net.resource.prefetch).toHaveBeenCalledWith(CSS, url);\n     });\n \n     it('calls for multiples urls', function() {\n       var urls = ['url-a-1.css', 'url-a-2.css'];\n       spf.net.style.prefetch(urls);\n       spf.array.each(urls, function(url) {\n-        expect(spf.net.resource.prefetch).toHaveBeenCalledWith(\n-            css, url);\n+        expect(spf.net.resource.prefetch).toHaveBeenCalledWith(CSS, url);\n       });\n     });\n \n", 'commit_subject': 'Merge pull request #150 from nicksay/resource-loading-streamline-tests', 'repo_name': 'youtube/spfjs', 'committer': {'name': 'Alex Nicksay', 'email': '7c2b58e326787f100693e0a135d10e022088ae3e@gmail.com', 'time_sec': '1416269169', 'tz_offset': '-300', 'date': {'seconds': '1416269169'}}, 'commit_tree': '1d3a0cb37e6d0159915693b3e913eb558a416370', 'commit_message': 'Merge pull request #150 from nicksay/resource-loading-streamline-tests\n\nCleanup spf.net.script and spf.net.style tests.', 'language_name': 'HTML', 'license': 'mit', 'hunks': "@@ -14,7 +14,7 @@ goog.require('spf.net.style');\n \n describe('spf.net.style', function() {\n \n-  var css = spf.net.resource.Type.CSS;\n+  var CSS = spf.net.resource.Type.CSS;\n \n   beforeEach(function() {\n     spyOn(spf.net.resource, 'load');\n@@ -29,9 +29,9 @@ describe('spf.net.style', function() {\n     it('passes a single url with name', function() {\n       var url = 'url-a.css';\n       var name = 'a';\n+      var fn = undefined;\n       spf.net.style.load(url, name);\n-      expect(spf.net.resource.load).toHaveBeenCalledWith(\n-          css, url, name, undefined);\n+      expect(spf.net.resource.load).toHaveBeenCalledWith(CSS, url, name, fn);\n     });\n \n     it('passes a single url with name and callback', function() {\n@@ -39,16 +39,15 @@ describe('spf.net.style', function() {\n       var name = 'a';\n       var fn = function() {};\n       spf.net.style.load(url, name, fn);\n-      expect(spf.net.resource.load).toHaveBeenCalledWith(\n-          css, url, name, fn);\n+      expect(spf.net.resource.load).toHaveBeenCalledWith(CSS, url, name, fn);\n     });\n \n     it('passes multiple urls with name', function() {\n       var urls = ['url-a-1.css', 'url-a-2.css'];\n       var name = 'a';\n+      var fn = undefined;\n       spf.net.style.load(urls, name);\n-      expect(spf.net.resource.load).toHaveBeenCalledWith(\n-          css, urls, name, undefined);\n+      expect(spf.net.resource.load).toHaveBeenCalledWith(CSS, urls, name, fn);\n     });\n \n     it('passes multiple urls with name and callback', function() {\n@@ -56,8 +55,7 @@ describe('spf.net.style', function() {\n       var name = 'a';\n       var fn = function() {};\n       spf.net.style.load(urls, name, fn);\n-      expect(spf.net.resource.load).toHaveBeenCalledWith(\n-          css, urls, name, fn);\n+      expect(spf.net.resource.load).toHaveBeenCalledWith(CSS, urls, name, fn);\n     });\n \n   });\n@@ -68,7 +66,7 @@ describe('spf.net.style', function() {\n     it('passes name', function() {\n       var name = 'a';\n       spf.net.style.unload(name);\n-      expect(spf.net.resource.unload).toHaveBeenCalledWith(css, name);\n+      expect(spf.net.resource.unload).toHaveBeenCalledWith(CSS, name);\n     });\n \n   });\n@@ -78,17 +76,16 @@ describe('spf.net.style', function() {\n \n     it('passes url', function() {\n       var url = 'url-a.css';\n+      var fn = undefined;\n       spf.net.style.get(url);\n-      expect(spf.net.resource.create).toHaveBeenCalledWith(\n-          css, url, undefined);\n+      expect(spf.net.resource.create).toHaveBeenCalledWith(CSS, url, fn);\n     });\n \n     it('passes url with function', function() {\n       var url = 'url-a.css';\n       var fn = function() {};\n       spf.net.style.get(url, fn);\n-      expect(spf.net.resource.create).toHaveBeenCalledWith(\n-          css, url, fn);\n+      expect(spf.net.resource.create).toHaveBeenCalledWith(CSS, url, fn);\n     });\n \n   });\n@@ -99,16 +96,14 @@ describe('spf.net.style', function() {\n     it('calls for a single url', function() {\n       var url = 'url-a.css';\n       spf.net.style.prefetch(url);\n-      expect(spf.net.resource.prefetch).toHaveBeenCalledWith(\n-          css, url);\n+      expect(spf.net.resource.prefetch).toHaveBeenCalledWith(CSS, url);\n     });\n \n     it('calls for multiples urls', function() {\n       var urls = ['url-a-1.css', 'url-a-2.css'];\n       spf.net.style.prefetch(urls);\n       spf.array.each(urls, function(url) {\n-        expect(spf.net.resource.prefetch).toHaveBeenCalledWith(\n-            css, url);\n+        expect(spf.net.resource.prefetch).toHaveBeenCalledWith(CSS, url);\n       });\n     });\n \n", 'addition_count': 13, 'deletion_count': 18, 'src_file': 'a/src/client/net/style_test.js', 'tgt_file': 'b/src/client/net/style_test.js', 'file_extension': '.js', 'before_file': "// Copyright 2014 Google Inc. All rights reserved.\n//\n// Use of this source code is governed by The MIT License.\n// See the LICENSE file for details.\n\n/**\n * @fileoverview Tests for dynamically loading styles.\n */\n\ngoog.require('spf.array');\ngoog.require('spf.net.resource');\ngoog.require('spf.net.style');\n\n\ndescribe('spf.net.style', function() {\n\n  var css = spf.net.resource.Type.CSS;\n\n  beforeEach(function() {\n    spyOn(spf.net.resource, 'load');\n    spyOn(spf.net.resource, 'unload');\n    spyOn(spf.net.resource, 'create');\n    spyOn(spf.net.resource, 'prefetch');\n  });\n\n\n  describe('load', function() {\n\n    it('passes a single url with name', function() {\n      var url = 'url-a.css';\n      var name = 'a';\n      spf.net.style.load(url, name);\n      expect(spf.net.resource.load).toHaveBeenCalledWith(\n          css, url, name, undefined);\n    });\n\n    it('passes a single url with name and callback', function() {\n      var url = 'url-a.css';\n      var name = 'a';\n      var fn = function() {};\n      spf.net.style.load(url, name, fn);\n      expect(spf.net.resource.load).toHaveBeenCalledWith(\n          css, url, name, fn);\n    });\n\n    it('passes multiple urls with name', function() {\n      var urls = ['url-a-1.css', 'url-a-2.css'];\n      var name = 'a';\n      spf.net.style.load(urls, name);\n      expect(spf.net.resource.load).toHaveBeenCalledWith(\n          css, urls, name, undefined);\n    });\n\n    it('passes multiple urls with name and callback', function() {\n    });\n      var name = 'a';\n      var fn = function() {};\n      spf.net.style.load(urls, name, fn);\n      expect(spf.net.resource.load).toHaveBeenCalledWith(\n          css, urls, name, fn);\n    });\n\n  });\n      var url = 'url-a.css';\n      var fn = undefined;\n      spf.net.style.get(url);\n      expect(spf.net.resource.create).toHaveBeenCalledWith(CSS, url, fn);\n    it('passes name', function() {\n      var name = 'a';\n      spf.net.style.unload(name);\n      expect(spf.net.resource.unload).toHaveBeenCalledWith(css, name);\n    });\n\n  });\n    });\n\n  });\n\n    it('passes url', function() {\n      var url = 'url-a.css';\n      spf.net.style.get(url);\n      expect(spf.net.resource.create).toHaveBeenCalledWith(\n          css, url, undefined);\n    });\n\n    it('passes url with function', function() {\n      var url = 'url-a.css';\n      var fn = function() {};\n      spf.net.style.get(url, fn);\n      expect(spf.net.resource.create).toHaveBeenCalledWith(\n          css, url, fn);\n    });\n\n  });\n    });\n\n  });\n\n    it('calls for a single url', function() {\n      var url = 'url-a.css';\n      spf.net.style.prefetch(url);\n      expect(spf.net.resource.prefetch).toHaveBeenCalledWith(\n          css, url);\n    });\n\n    it('calls for multiples urls', function() {\n      var urls = ['url-a-1.css', 'url-a-2.css'];\n      spf.net.style.prefetch(urls);\n      spf.array.each(urls, function(url) {\n        expect(spf.net.resource.prefetch).toHaveBeenCalledWith(\n            css, url);\n      });\n    });\n\n", 'message': 'Merge pull request #150 from nicksay/resource-loading-streamline-tests\n\nCleanup spf.net.script and spf.net.style tests.', 'author_name': 'Alex Nicksay', 'lang': 'js'}