<commit_before>(function ( window, document, undefined, Butter ) {

  module( "Previewer", {
    setup: function () {
    },
    teardown: function () {
    }
  } );

  test( "Iframe empty check", function () {
    expect( 1 );
    ok( document.getElementById( "notIframe" ).innerHTML === "", "Iframe is initially empty" );
  } );

  test( "Start Previewer", function() {
    expect( 0 );
    var butter = new Butter();

    butter.previewer( {
      layout: "../../../src/modules/previewer/layout.html",
      target: "notIframe",
      popcornURL: "http://popcornjs.org/code/dist/popcorn-complete.js",
      media: "http://videos-cdn.mozilla.net/serv/webmademovies/Moz_Doc_0329_GetInvolved_ST.webm",
      callback: function() {
        test( "Inside Callback", function() {
          expect( 9 );
          var layoutSrc = document.getElementById( "notIframe" ).src;
          ok( true, "Inside callback function" );
          ok( document.getElementById( "notIframe" ).contentWindow.document.innerHTML !== "", "Iframe has contents" );
          ok( layoutSrc.split("/")[ layoutSrc.split("/").length - 1 ] === "layout.html", "Iframes source is layout.html" );
          ok( butter.getTargets().length === 1, "Targets successfully scraped" );
          ok( butter.getTargets()[ 0 ].getName() === "div2", "Targets getName function working" );
          ok( butter.getAllMedia().length === 2, "Media targets successfully scraped" );
          ok( butter.getAllMedia()[ 0 ].getName() === "outerVideo", "Media targets getName function working" );
          ok( butter.getAllMedia()[ 0 ].getMedia() === "http://videos-cdn.mozilla.net/serv/webmademovies/Moz_Doc_0329_GetInvolved_ST.webm", "Media targets getMedia function working" );
          butter.buildPopcorn( "videoz", function() {
            test( "Popcorn functionality", function() {
              expect( 1 );
              
              ok( !!document.getElementById( "notIframe" ).contentWindow.popcorn, "Instance of popcorn available" );
            } );
          } );

          ok( butter.getPopcorn() !== "", "getPopcorn function working properly" );

        var track = butter.getTracks()[ 0 ] || butter.addTrack( new Butter.Track() );
        butter.addTrackEvent( track, new Butter.TrackEvent( {
          start: 1, end: 100, type: type, popcornOptions: {
            start: 1,
            end: 10,
            text: "ITS WORKING",
            target: butter.getTargets()[ 0 ].getName()
          }
        } ) );

          
        } );
      }
    } );
  } );

} )( window, document, undefined, Butter );<commit_msg>More unit tests for the previewer<commit_after>(function ( window, document, undefined, Butter ) {

  module( "Previewer", {
    setup: function () {
    },
    teardown: function () {
    }
  } );

  var butter = new Butter(),
      oldVideo;

  test( "Iframe empty check", function () {
    expect( 1 );
    ok( document.getElementById( "notIframe" ).innerHTML === "", "Iframe is initially empty" );
  } );

  test( "Inside Callback", function() {
    expect( 0 );

    butter.previewer( {
      layout: "../../../src/modules/previewer/layout.html",
      target: "notIframe",
      popcornURL: "http://popcornjs.org/code/dist/popcorn-complete.js",
      media: "http://videos-cdn.mozilla.net/serv/webmademovies/Moz_Doc_0329_GetInvolved_ST.webm",
      callback: function() {

          expect( 9 );
          var layoutSrc = document.getElementById( "notIframe" ).src;
          ok( true, "Inside callback function" );
          ok( document.getElementById( "notIframe" ).contentWindow.document.innerHTML !== "", "Iframe has contents" );
          ok( layoutSrc.split("/")[ layoutSrc.split("/").length - 1 ] === "layout.html", "Iframes source is layout.html" );
          ok( butter.getTargets().length === 1, "Targets successfully scraped" );
          ok( butter.getTargets()[ 0 ].getName() === "div2", "Targets getName function working" );
          ok( butter.getAllMedia().length === 1, "Media targets successfully scraped" );
          ok( butter.getAllMedia()[ 0 ].getName() === "outerVideo", "Media targets getName function working" );
          ok( butter.getAllMedia()[ 0 ].getMedia() === "http://videos-cdn.mozilla.net/serv/webmademovies/Moz_Doc_0329_GetInvolved_ST.webm", "Media targets getMedia function working" );
          butter.buildPopcorn( butter.getAllMedia()[ 0 ], function() {
            test( "Popcorn functionality", function() {
              expect( 3 );
              
              ok( !!document.getElementById( "notIframe" ).contentWindow.Popcorn, "Popcorn is now available for use" );
              ok ( !!document.getElementById( "notIframe" ).contentWindow[ "popcorn0" ], "Uniquely named instance of popcorn is available" );
              ok ( typeof butter.getRegistry() === "object", "getRegistry is working properly" );
            } );
          } );

          ok( butter.getPopcorn() !== "", "getPopcorn function working properly" );

          var track = butter.getTracks()[ 0 ] || butter.addTrack( new Butter.Track() );
          butter.addTrackEvent( track, new Butter.TrackEvent( {
            start: 1, end: 100, type: 'footnote', popcornOptions: {
              start: 1,
              end: 10,
              text: "ITS WORKING",
              target: butter.getTargets()[ 0 ].getName()
            }
          } ) ); 
      }      
        } );

    } );

  butter.listen( "trackeventadded", function( e ) {
    test ( "TrackEvent Added", function() {
      ok( true, "Inside track Event added" );
      var add = function() {
        for( item in butter.getTrackEvents() ) {
        if( butter.getTrackEvents()[ item ].length > 0 ) {
          ok( butter.getTrackEvents()[ item ].length > 0, "Track Event exists" );
          

            butter.removeTrackEvent( e.data.getName() );
        }
        else { 
         setTimeout( function() { add(); }, 10 ); 
        }
        } 
      }
      add();
      
    } );
  } );

  butter.listen( "trackeventremoved", function( e ) {
     test( "TrackEvent Removed", function() {

          var media = butter.addMedia( { 
            name: "outerVideo", 
            media: "http://clips.vorwaerts-gmbh.de/VfE.ogv" 
          } );

          ok( true, "Inside trackEvent removed" );
          var remove = function( item ) {
            if( butter.getTrackEvents()[ item ][ 0 ] === undefined ) {

  butter.listen( "mediachanged", function( e ) {

    test( "Media Changed", function() {

        ok( true, "Inside Media Changed listener" );
        ok( butter.getAllMedia()[ 0 ].getName() !== oldVideo, "Current video is different from previous video" );

    } );
  } );
              butter.setMedia( media );
              
            } else {
             setTimeout( function() {
              remove( item );
             }, 10 ); 
            }
          }
          for( item in butter.getTrackEvents() ) {
            ok( butter.getTrackEvents()[ item ][ 0 ] === undefined, "No Track Events Exist" );
            remove( item );
          }
        } );
  } );

} )( window, document, undefined, Butter );
{'fraction_non_alphanumeric': 0.15482054890921887, 'fraction_numerical': 0.009429978888106967, 'mean_word_length': 2.2388331814038285, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6808216', 'n_tokens_mistral': 2149, 'n_tokens_neox': 2029, 'n_words': 499}