Uname: Linux webm016.cluster127.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 7.4.33 [ PHP INFO ] PHP os: Linux
Server Ip: 54.36.31.145
Your Ip: 216.73.216.182
User: homesquasz (91404) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : NamespaceSpec.js
describe("Namespace Tests", function() {
  var sourceJS = "temp/bootstrap-slider.js";
  var defaultNamespace = 'slider';
  var alternateNamespace = 'bootstrapSlider';

  it("should always set the plugin namespace to 'bootstrapSlider'", function(done) {
    $.when($.getScript(sourceJS)).then(function() {
      expect($.fn.bootstrapSlider).toBeDefined();
      done();   
    });
  });

  it("should set the plugin namespace to 'slider' if the namespace is available", function(done) {
    $.when($.getScript(sourceJS)).then(function() {
      expect($.fn.slider).toBeDefined();
      done();
    });
  });

  it("should print a console warning if the 'slider' namespace is already bound", function(done) {
    $.fn.slider = function() {};
    spyOn(window.console, "warn");

    $.when($.getScript(sourceJS)).then(function() {
      var expectedWarningMessage = "bootstrap-slider.js - WARNING: $.fn.slider namespace is already bound. Use the $.fn.bootstrapSlider namespace instead.";
      expect(window.console.warn).toHaveBeenCalledWith(expectedWarningMessage);
      done();
    });
  });

  it("Should not create instance when 'slider' namespace is in use", function(done) {
    $.fn.slider = function() {};  // Overwrite temporarily

    $.when($.getScript(sourceJS)).then(function() {
      var $testSlider = $('#testSlider1').bootstrapSlider();

      var sliderInst = $testSlider.data(defaultNamespace);
      expect(sliderInst).toBeUndefined();

      $testSlider.bootstrapSlider('destroy');

      done();
    });
  });

  it("Should create instance associated with the alternate 'bootstrapSlider' namespace", function(done) {
    $.fn.slider = function() {};

    $.when($.getScript(sourceJS)).then(function() {
      var $testSlider = $('#testSlider1').bootstrapSlider();

      var sliderInst = $testSlider.data(alternateNamespace);
      expect(sliderInst).toBeTruthy();

      $testSlider.bootstrapSlider('destroy');

      done();
    });
  });

  afterEach(function(done) {
    /*
      Set the namespaces back to undefined and reload slider
      So that namespace is returned to $.fn.slider
    */
    $.fn.bootstrapSlider = undefined;
    $.fn.slider = undefined;

    $.when($.getScript(sourceJS)).then(function() {
      done();
    });
  });

});
© 2026 GrazzMean