www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

styleTest.js (1465B)


      1 "use strict";
      2 
      3 describe("Zotero.Styles", function() {
      4 	var styleID = "http://www.zotero.org/styles/cell";
      5 	var stylePath = OS.Path.join(getTestDataDirectory().path, 'cell.csl');
      6 	var styleFile = Zotero.File.pathToFile(stylePath);
      7 	var style;
      8 	
      9 	before(function* () {
     10 		yield Zotero.Styles.init();
     11 		style = yield Zotero.File.getContentsAsync(stylePath);
     12 	});
     13 	
     14 	describe("Zotero.Styles.install", function() {
     15 		afterEach(`${styleID} style should be installed`, function* (){
     16 			assert.isOk(Zotero.Styles.get(styleID));
     17 			yield Zotero.Styles.get(styleID).remove();
     18 		});
     19 		
     20 		it("should install the style from string", function* () {
     21 			yield Zotero.Styles.install(style, styleID, true);
     22 		});
     23 		
     24 		it("should install the style from nsIFile", function* () {
     25 			yield Zotero.Styles.install(styleFile, styleID, true);
     26 		});
     27 
     28 		it("should install the style from url", function* () {
     29 			var getContentsFromURLAsync = Zotero.File.getContentsFromURLAsync;
     30 			sinon.stub(Zotero.File, 'getContentsFromURLAsync').callsFake(function(style) {
     31 				if (style.url == styleID) {
     32 					return Zotero.Promise.resolve(style);
     33 				} else {
     34 					return getContentsFromURLAsync.apply(Zotero.File, arguments);
     35 				}
     36 			});
     37 			yield Zotero.Styles.install({url: styleID}, styleID, true);
     38 			Zotero.File.getContentsFromURLAsync.restore();
     39 		});
     40 		
     41 		it("should install the style from file path", function* () {
     42 			yield Zotero.Styles.install({file: stylePath}, styleID, true);
     43 		})
     44 	});
     45 });