<commit_before>/**
 * This module implements the viewer's specification (tests).
 *
 */

define(['viewerjs'], function(viewerjs) {

  describe('viewerjs', function() {

    window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000;

    var testDataDir = 'bower_components/mri_testdata/';

    var fileObjArr = [{url: testDataDir + 'volumes/nii/s34654_df.nii', name: 's34654_df.nii',
      remote: true}];

    // append a container for the whole viewer
    var container = $('<div id="viewercontainer"></div>');
    $(document.body).append(container);

    var view; // viewer

    describe('viewerjs Initialization', function() {

      beforeEach(function() {

        // Create a new viewerjs.Viewer object
        view = new viewerjs.Viewer('viewercontainer');
      });

      afterEach(function() {

        // Destroy viewer
        view.destroy();
      });

      it('viewerjs.Viewer.prototype.addTrash adds a trash to the viewer',

        function() {

          view.addTrash();
          expect($('.view-trash', view.container).length).toEqual(1);
          expect(view.trash.length).toEqual(1);
        }
      );

      it('viewerjs.Viewer.prototype.addRenderersBox adds a renderers box to' +
        ' the viewer',

        function() {

          view.container.sortable();
          view.addRenderersBox();
          expect($('.view-renderers', view.container).length).toEqual(1);
          expect(view.rBox.container.length).toEqual(1);
        }
      );

      it('viewerjs.Viewer.prototype.addToolBar adds a toolbar to the viewer',

        function() {

          view.container.sortable();
          view.addRenderersBox(); // a renderers box must be added first
          view.addToolBar();
          expect($('.view-toolbar', view.container).length).toEqual(1);
          expect(view.toolBar.container.length).toEqual(1);
        }
      );

      it('viewerjs.Viewer.prototype.init initializes the viewer html',

        function() {

          view.init();
          expect(view.container.length).toEqual(1);
          expect(view.rBox.container.length).toEqual(1);
          expect(view.toolBar.container.length).toEqual(1);
        }
      );

      it('viewerjs.Viewer.prototype.buildImgFileArr builds viewer main data' +
        ' structure: view.imgFileArr',

        function() {

          var imgFileArr = view.buildImgFileArr(fileObjArr);

          expect(imgFileArr[0]).toEqual({
            id: 0,
            baseUrl: testDataDir + 'volumes/nii/',
            imgType: 'vol',
            files: [fileObjArr[0]],
          });
        }
      );

      it('rendererjs.Renderer.prototype.addThumbnailsBar adds a new thumbnails' +
        ' bar to the viewer',

        function(done) {

          view.init();

          view.addThumbnailsBar(view.buildImgFileArr(fileObjArr), function() {

            expect($('.view-thumbnailsbar', view.container).length).toEqual(1);
            expect(view.thBars[0].container.length).toEqual(1);
            done();
          });<commit_msg>specs with simplified array of file objects<commit_after>/**
 * This module implements the viewer's specification (tests).
 *
 */

define(['viewerjs'], function(viewerjs) {

  describe('viewerjs', function() {

    window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000;

    var testDataDir = 'bower_components/mri_testdata/';

    var fileObjArr = [{url: testDataDir + 'volumes/nii/s34654_df.nii'}];

    // append a container for the whole viewer
    var container = $('<div id="viewercontainer"></div>');
    $(document.body).append(container);

    var view; // viewer

    describe('viewerjs Initialization', function() {

      beforeEach(function() {

        // Create a new viewerjs.Viewer object
        view = new viewerjs.Viewer('viewercontainer');
      });

      afterEach(function() {

        // Destroy viewer
        view.destroy();
      });

      it('viewerjs.Viewer.prototype.addTrash adds a trash to the viewer',

        function() {

          view.addTrash();
          expect($('.view-trash', view.container).length).toEqual(1);
          expect(view.trash.length).toEqual(1);
        }
      );

      it('viewerjs.Viewer.prototype.addRenderersBox adds a renderers box to' +
        ' the viewer',

        function() {

          view.container.sortable();
          view.addRenderersBox();
          expect($('.view-renderers', view.container).length).toEqual(1);
          expect(view.rBox.container.length).toEqual(1);
        }
      );

      it('viewerjs.Viewer.prototype.addToolBar adds a toolbar to the viewer',

        function() {

          view.container.sortable();
          view.addRenderersBox(); // a renderers box must be added first
          view.addToolBar();
          expect($('.view-toolbar', view.container).length).toEqual(1);
          expect(view.toolBar.container.length).toEqual(1);
        }
      );

      it('viewerjs.Viewer.prototype.init initializes the viewer html',

        function() {

          view.init();
          expect(view.container.length).toEqual(1);
          expect(view.rBox.container.length).toEqual(1);
          expect(view.toolBar.container.length).toEqual(1);
        }
      );

      it('viewerjs.Viewer.prototype.buildImgFileArr builds viewer main data' +
        ' structure: view.imgFileArr',

        function() {

          var imgFileArr = view.buildImgFileArr(fileObjArr);

          var fObj = fileObjArr[0];
          fObj.name = 's34654_df.nii';
          fObj.remote = true;

          expect(imgFileArr[0]).toEqual({
            id: 0,
            baseUrl: testDataDir + 'volumes/nii/',
            imgType: 'vol',
            files: [fObj],
          });
        }
      );

      it('rendererjs.Renderer.prototype.addThumbnailsBar adds a new thumbnails' +
        ' bar to the viewer',

        function(done) {

          view.init();

          view.addThumbnailsBar(view.buildImgFileArr(fileObjArr), function() {

            expect($('.view-thumbnailsbar', view.container).length).toEqual(1);
            expect(view.thBars[0].container.length).toEqual(1);
            done();
          });
{'fraction_non_alphanumeric': 0.13925294888597642, 'fraction_numerical': 0.009829619921363041, 'mean_word_length': 2.2438894792773647, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6053250', 'n_tokens_mistral': 1865, 'n_tokens_neox': 1782, 'n_words': 313}