<commit_before>define(['underscore'], function(_){

  return function(xstr, ystr){

    var x = parseInt(xstr, 10),
        y = parseInt(ystr, 10),
        selected = [[x,y]];

    if(this.board[x][y].adjacent === 0){

      var stack = [selected[0]];

      while(stack.length > 0){
        var cur = stack.pop(),
            cx = cur[0],
            cy = cur[1],
            left = false,
            right = false;

        // move upward
        while(cy - 1 >= 0 && this.board[cx][cy - 1].adjacent === 0){
          cy -= 1;
        }

        // fill downward
        while(cy < this.height && this.board[cx][cy].adjacent === 0){

          // add this tile
          if(!(cx === x && cy === y)){
            selected.push([cx, cy]);
            this.board[cx][cy].revealed = true;
          }

          // check for stack opportunities
          if(cx > 0){
            if(this.board[cx-1][cy].adjacent === 0 && !this.board[cx-1][cy].revealed){
              if(!left){
                stack.push([cx-1,cy]);
                left = true;
              }
            }else
            if(left){
              left = false;
            }
          }

          if(cx < this.width - 1){
            if(this.board[cx+1][cy].adjacent === 0 && !this.board[cx+1][cy].revealed){
              if(!right){
                stack.push([cx+1,cy]);
                right = true;
              }
            }else
            if(right){
              right = false;
            }
          }

          cy += 1;

        } // done filling downward

      } // done with stack

    } // done selecting all empty tiles

    return selected;

  };

});<commit_msg>Selecting perimeter and diagonally adjacent zero-adjacency fields.<commit_after>define(['underscore'], function(_){

  return function(xstr, ystr){

    var self = this,
        x = parseInt(xstr, 10),
        y = parseInt(ystr, 10),
        selected = [[x,y]],
        perimeter = [],
        cx, cy;

    if(this.board[x][y].adjacent === 0){

      var stack = [selected[0]];

      var checkDiagonal = function(dx, dy){
        if (!self.board[dx][dy].revealed) {
          if (self.board[dx][dy].adjacent === 0) {
            stack.push([dx,dy]);
          } else {
            perimeter.push([dx,dy]);
            self.board[dx][dy].revealed = true;
          }
        }
      };

      while(stack.length > 0){
        var cur = stack.pop(),
            left = false,
            right = false;

        cx = cur[0];
        cy = cur[1];

        // move upward
        while(cy - 1 >= 0 && this.board[cx][cy - 1].adjacent === 0){
          cy -= 1;
        }

        // add upper cap to perimeter
        if(cy - 1 >= 0){
          perimeter.push([cx, cy - 1]);
          this.board[cx][cy-1].revealed = true;

          if(cx-1 >= 0) {
            checkDiagonal(cx - 1, cy - 1);
          }

          if (cx + 1 < this.width) {
            checkDiagonal(cx + 1, cy - 1);
          }
        }

        // fill downward
        while(cy < this.height && this.board[cx][cy].adjacent === 0){

          // add this tile
          if(!(cx === x && cy === y)){
            selected.push([cx, cy]);
            this.board[cx][cy].revealed = true;
          }

          // check for stack opportunities
          if(cx > 0){
            if(!this.board[cx-1][cy].revealed){
              if(this.board[cx-1][cy].adjacent === 0) {
                if (!left) {
                  stack.push([cx - 1, cy]);
                  left = true;
                }
              }else{
                perimeter.push([cx - 1, cy]);
                this.board[cx - 1][cy].revealed = true;
              }
            }else
            if(left){
              left = false;
            }
          }

          if(cx < this.width - 1){
            if(!this.board[cx+1][cy].revealed){
              if(this.board[cx+1][cy].adjacent === 0) {
                if (!right) {
                  stack.push([cx + 1, cy]);
                  right = true;
                }
              }else{
                perimeter.push([cx + 1, cy]);
                this.board[cx + 1][cy].revealed = true;
              }
            }else
            if(right){
              right = false;
            }
          }

          cy += 1;

        } // done filling downward

        // add lower cap to perimeter
        if(cy < this.height){
          perimeter.push([cx, cy]);
          this.board[cx][cy].revealed = true;

          if(cx-1 >= 0){
            checkDiagonal(cx - 1, cy);
          }

          if(cx+1 < this.width){
            checkDiagonal(cx+1, cy);
          }
        }

      } // done with stack

    } // done selecting all empty tiles

    return selected.concat(perimeter);

  };

});<|endoftext|>


<commit_before>// Define variables to load in jFrame's Gulpfile
var gulp 			= require('gulp'),
	postcss			= require('gulp-postcss')
	autoprefixer	= require('autoprefixer')
	cssnext			= require('cssnext')
	precss			= require('precss');

// This is the Gulp task named 'css' which executes the following function
gulp.task('css', function(){

	// Define PostCSS plugins here, we'll pass them below
	var processors = [
		autoprefixer,
		cssnext,
		precss
	];

	// This is where the files for processing are located (/.src/*.css)
	return gulp.src('./src/*.css')
		// PostCSS plugins (defined above) are added to the pipe here
		.pipe(postcss(processors))
		// This is where the processed files get piped to ('./dest')
		.pipe(gulp.dest('./dest'));
});<commit_msg>autoprefixer support last 2 browser versions<commit_after>// Define variables to load in jFrame's Gulpfile
var gulp 			= require('gulp'),
	postcss			= require('gulp-postcss')
	autoprefixer	= require('autoprefixer')
	cssnext			= require('cssnext')
	precss			= require('precss');

// This is the Gulp task named 'css' which executes the following function
gulp.task('css', function(){

	// Define PostCSS plugins here, we'll pass them below
	var processors = [
		autoprefixer({
			browsers: ['last 2 versions']
		}),
		cssnext,
		precss
	];

	// This is where the files for processing are located (/.src/*.css)
	return gulp.src('./src/*.css')
		// PostCSS plugins (defined above) are added to the pipe here
		.pipe(postcss(processors))
		// This is where the processed files get piped to ('./dest')
		.pipe(gulp.dest('./dest'));
});<|endoftext|>


<commit_before>'use strict'

const common = [
  'utility.js',
  // 'reference/HTMLReferenceElement.js',
  // 'reference/Manager.js',
  'data/httpproxy.js',
  'driver.js',
  'loader.js',
  'state.js',
  'view/registry.js',
  'view/component.js'
]

require('localenvironment')
require('colors')

const gulp = require('gulp')
const gutil = require('gulp-util')
const concat = require('gulp-concat')
const uglify = require('gulp-uglify')
const babel = require('gulp-babel')
const cp = require('child_process')
const header = require('gulp-header')
const footer = require('gulp-footer')
const sourcemaps = require('gulp-sourcemaps')
const ShortBus = require('shortbus')
const del = require('del')
const MustHave = require('musthave')
const mh = new MustHave({
  throwOnError: false
})
const GithubPublisher = require('publish-release')
const fs = require('fs')
const path = require('path')
const pkg = require('./package.json')

const headerComment = `/**\n  * v${pkg.version} generated on: ${(new Date())}\n`
  + `\n  * Copyright (c) 2014-${(new Date()).getFullYear()}, `
  + 'Ecor Ventures LLC. All Rights Reserved. See LICENSE (BSD).\n  */\n'

const DIR = {
  source: path.resolve('./src'),
  dist: path.resolve('./dist')
}

const minifyConfig = {
  presets: ['es2015', 'es2017'],
  mangle: true,
  compress: {
    dead_code: true,
    global_defs: {
      DEBUG: false
    },
    warnings: true,
    drop_debugger: true,
    unused: true,
    if_return: true,
    passes: 3
  }
}

const babelConfig = {
  presets: ['es2015', 'es2017']
}

// Build a release
gulp.task('build', ['clean', 'generate'])

// Check versions for Bower & npm
// gulp.task('version', function (next) {
//   console.log('Checking versions.')
//
//   // Sync Bower
//   var bower = require('./bower.json')
//   if (bower.version !== pkg.version) {
//     console.log('Updating bower package.')
//     bower.version = pkg.version
//     fs.writeFileSync(path.resolve('./bower.json'), JSON.stringify(bower, null, 2))
//   }
// })

const expand = function (array) {
  return array.map(function (file) {
    return path.join(DIR.source, file)
  })
}

const walk = function (dir) {
  let files = []
  fs.readdirSync(dir).forEach(function (filepath) {
    filepath = path.join(dir, filepath)
    const stat = fs.statSync(filepath)
    if (stat.isDirectory()) {
      files = files.concat(walk(filepath))
    } else {
      files.push(filepath)
    }
  })
  return files
}

// Create a clean build
gulp.task('clean', function (next) {
  gutil.log('Cleaning distribution.')

  try {
    fs.accessSync(DIR.dist, fs.F_OK)
    del.sync(DIR.dist)
  } catch (e) {}

  fs.mkdir(DIR.dist, next)
})

gulp.task('generate', function () {
  gutil.log('Generating distribution files in ', DIR.dist)

  const tasks = new ShortBus()
  const mapRoot = 'https://cdn.author.io/ngnx/' + pkg.version
  const srcmapcfg = {
    includeContent: true,
    sourceMappingURL: function (file) {
      return `${mapRoot}/${file.relative}.map`
    },
    sourceURL: function (file) {
      return file.relative.replace('.min.js', '.js')
    }
  }

  common.forEach(function (filename) {
    tasks.add(`Generating common file: ${filename}`, function (cont) {
      gulp.src(path.join(DIR.source, filename))
        .pipe(concat(filename.replace('.js', '.min.js').replace(path.sep, '.')))
        .pipe(babel(babelConfig))
        .pipe(uglify(minifyConfig))
        .pipe(header(headerComment))
        .pipe(sourcemaps.write('./sourcemaps', srcmapcfg))
        .pipe(gulp.dest(DIR.dist))
        .on('end', cont)
    })
  })

  // Generate debug library
  tasks.add('Generating debug version: debug.js', function (cont) {
    gulp.src(expand(common))
      .pipe(concat('debug.js'))
      .pipe(babel(babelConfig))
      .pipe(header(headerComment))
      .pipe(footer(`\nObject.defineProperty(NGNX, 'version', NGN.const('${pkg.version}')); console.info('%cDebugging%c NGNX v${pkg.version}', 'font-weight: bold;', 'font-weight: normal')`))
      .pipe(gulp.dest(DIR.dist))
      .on('end', cont)
  })

  // Generate production library
  tasks.add('Generate production library: complete.min.js', function (cont) {
    return gulp.src(expand(common))
      .pipe(concat('complete.min.js'))
      .pipe(babel(babelConfig))
      .pipe(uglify(minifyConfig))
      .pipe(header(headerComment))
      .pipe(footer(`\nObject.defineProperty(NGNX, 'version', NGN.const('${pkg.version}'))`))
      .pipe(sourcemaps.write('./sourcemaps', srcmapcfg))
      .pipe(gulp.dest(DIR.dist))
      .on('end', cont)
  })

  tasks.on('stepstarted', (step) => gutil.log(`${step.number}) ${step.name}`))

  tasks.process(true)
})

gulp.task('prereleasecheck', function (next) {
  gutil.log('Checking if package already exists.')

  const child = cp.spawn('npm', ['info', pkg.name])
  let data = ""

  child.stdout.on('data', function (chunk) {
    data += chunk.toString()
  })

  child.on('close', function () {
    const re = new RegExp('latest: \'' + pkg.version + '\'')

    if (re.exec(data) === null) {
      next()
    } else {
      gutil.log(`The version has not changed (${pkg.version}). A new release is unnecessary. Aborting deployment with success code.`)
      process.exit(0)
    }
  })
})

gulp.task('release', function (next) {
  gutil.log('Checking if package already exists.')

  const child = cp.spawn('npm', ['info', pkg.name])
  let data = ""

  child.stdout.on('data', function (chunk) {
    data += chunk.toString()
  })

  child.on('close', function () {
    const re = new RegExp(`latest: '${pkg.version}'`)

    if (re.exec(data) === null) {
      if (!mh.hasAll(process.env, 'GITHUB_TOKEN', 'GITHUB_ACCOUNT', 'GITHUB_REPO')) {
        throw new Error(`Release not possible. Missing data: ${mh.missing.join(', ')}`)
      }

      // Check if the release already exists.
      const https = require('https')

      https.get({
        hostname: 'api.github.com',
        path: `/repos/${process.env.GITHUB_ACCOUNT}/${process.env.GITHUB_REPO}/releases`,
        headers: {
          'user-agent': 'Release Checker'
        }
      }, function (res) {
        let data = ""

        res.on('data', function (chunk) {
          data += chunk
        })

        res.on('error', function (err) {
          throw err
        })

        res.on('end', function () {
          data = JSON.parse(data).filter(function (release) {
            return release.tag_name === pkg.version
          })

          if (data.length > 0) {
            gutil.log(`Release ${pkg.version} already exists. Aboting without error.`)

            process.exit(0)
          }

          const assets = walk(DIR.dist).sort()

          GithubPublisher({
            token: process.env.GITHUB_TOKEN,
            owner: process.env.GITHUB_ACCOUNT,
            repo: process.env.GITHUB_REPO,
            tag: pkg.version,
            name: pkg.version,
            notes: `Releasing v${pkg.version}`,
            draft: false,
            prerelease: false,
            reuseRelease: true,
            reuseDraftOnly: true,
            assets: assets,
            // apiUrl: 'https://myGHEserver/api/v3',
            target_commitish: 'master'
          }, function (err, release) {
            if (err) {
              err.errors.forEach((e) => console.error((`${e.resource} ${e.code}`).red.bold))

              process.exit(1)
            }

            gutil.log(release)
          })
        })
      })
    }
  })
})
<commit_msg>Troubleshoot library 3<commit_after>'use strict'

const common = [
  'utility.js',
  'reference/HTMLReferenceElement.js',
  // 'reference/Manager.js',
  'data/httpproxy.js',
  'driver.js',
  'loader.js',
  'state.js',
  'view/registry.js',
  'view/component.js'
]

require('localenvironment')
require('colors')

const gulp = require('gulp')
const gutil = require('gulp-util')
const concat = require('gulp-concat')
const uglify = require('gulp-uglify')
const babel = require('gulp-babel')
const cp = require('child_process')
const header = require('gulp-header')
const footer = require('gulp-footer')
const sourcemaps = require('gulp-sourcemaps')
const ShortBus = require('shortbus')
const del = require('del')
const MustHave = require('musthave')
const mh = new MustHave({
  throwOnError: false
})
const GithubPublisher = require('publish-release')
const fs = require('fs')
const path = require('path')
const pkg = require('./package.json')

const headerComment = `/**\n  * v${pkg.version} generated on: ${(new Date())}\n`
  + `\n  * Copyright (c) 2014-${(new Date()).getFullYear()}, `
  + 'Ecor Ventures LLC. All Rights Reserved. See LICENSE (BSD).\n  */\n'

const DIR = {
  source: path.resolve('./src'),
  dist: path.resolve('./dist')
}

const minifyConfig = {
  presets: ['es2015', 'es2017'],
  mangle: true,
  compress: {
    dead_code: true,
    global_defs: {
      DEBUG: false
    },
    warnings: true,
    drop_debugger: true,
    unused: true,
    if_return: true,
    passes: 3
  }
}

const babelConfig = {
  presets: ['es2015', 'es2017']
}

// Build a release
gulp.task('build', ['clean', 'generate'])

// Check versions for Bower & npm
// gulp.task('version', function (next) {
//   console.log('Checking versions.')
//
//   // Sync Bower
//   var bower = require('./bower.json')
//   if (bower.version !== pkg.version) {
//     console.log('Updating bower package.')
//     bower.version = pkg.version
//     fs.writeFileSync(path.resolve('./bower.json'), JSON.stringify(bower, null, 2))
//   }
// })

const expand = function (array) {
  return array.map(function (file) {
    return path.join(DIR.source, file)
  })
}

const walk = function (dir) {
  let files = []
  fs.readdirSync(dir).forEach(function (filepath) {
    filepath = path.join(dir, filepath)
    const stat = fs.statSync(filepath)
    if (stat.isDirectory()) {
      files = files.concat(walk(filepath))
    } else {
      files.push(filepath)
    }
  })
  return files
}

// Create a clean build
gulp.task('clean', function (next) {
  gutil.log('Cleaning distribution.')

  try {
    fs.accessSync(DIR.dist, fs.F_OK)
    del.sync(DIR.dist)
  } catch (e) {}

  fs.mkdir(DIR.dist, next)
})

gulp.task('generate', function () {
  gutil.log('Generating distribution files in ', DIR.dist)

  const tasks = new ShortBus()
  const mapRoot = 'https://cdn.author.io/ngnx/' + pkg.version
  const srcmapcfg = {
    includeContent: true,
    sourceMappingURL: function (file) {
      return `${mapRoot}/${file.relative}.map`
    },
    sourceURL: function (file) {
      return file.relative.replace('.min.js', '.js')
    }
  }

  common.forEach(function (filename) {
    tasks.add(`Generating common file: ${filename}`, function (cont) {
      gulp.src(path.join(DIR.source, filename))
        .pipe(concat(filename.replace('.js', '.min.js').replace(path.sep, '.')))
        .pipe(babel(babelConfig))
        .pipe(uglify(minifyConfig))
        .pipe(header(headerComment))
        .pipe(sourcemaps.write('./sourcemaps', srcmapcfg))
        .pipe(gulp.dest(DIR.dist))
        .on('end', cont)
    })
  })

  // Generate debug library
  tasks.add('Generating debug version: debug.js', function (cont) {
    gulp.src(expand(common))
      .pipe(concat('debug.js'))
      .pipe(babel(babelConfig))
      .pipe(header(headerComment))
      .pipe(footer(`\nObject.defineProperty(NGNX, 'version', NGN.const('${pkg.version}')); console.info('%cDebugging%c NGNX v${pkg.version}', 'font-weight: bold;', 'font-weight: normal')`))
      .pipe(gulp.dest(DIR.dist))
      .on('end', cont)
  })

  // Generate production library
  tasks.add('Generate production library: complete.min.js', function (cont) {
    return gulp.src(expand(common))
      .pipe(concat('complete.min.js'))
      .pipe(babel(babelConfig))
      .pipe(uglify(minifyConfig))
      .pipe(header(headerComment))
      .pipe(footer(`\nObject.defineProperty(NGNX, 'version', NGN.const('${pkg.version}'))`))
      .pipe(sourcemaps.write('./sourcemaps', srcmapcfg))
      .pipe(gulp.dest(DIR.dist))
      .on('end', cont)
  })

  tasks.on('stepstarted', (step) => gutil.log(`${step.number}) ${step.name}`))

  tasks.process(true)
})

gulp.task('prereleasecheck', function (next) {
  gutil.log('Checking if package already exists.')

  const child = cp.spawn('npm', ['info', pkg.name])
  let data = ""

  child.stdout.on('data', function (chunk) {
    data += chunk.toString()
  })

  child.on('close', function () {
    const re = new RegExp('latest: \'' + pkg.version + '\'')

    if (re.exec(data) === null) {
      next()
    } else {
      gutil.log(`The version has not changed (${pkg.version}). A new release is unnecessary. Aborting deployment with success code.`)
      process.exit(0)
    }
  })
})

gulp.task('release', function (next) {
  gutil.log('Checking if package already exists.')

  const child = cp.spawn('npm', ['info', pkg.name])
  let data = ""

  child.stdout.on('data', function (chunk) {
    data += chunk.toString()
  })

  child.on('close', function () {
    const re = new RegExp(`latest: '${pkg.version}'`)

    if (re.exec(data) === null) {
      if (!mh.hasAll(process.env, 'GITHUB_TOKEN', 'GITHUB_ACCOUNT', 'GITHUB_REPO')) {
        throw new Error(`Release not possible. Missing data: ${mh.missing.join(', ')}`)
      }

      // Check if the release already exists.
      const https = require('https')

      https.get({
        hostname: 'api.github.com',
        path: `/repos/${process.env.GITHUB_ACCOUNT}/${process.env.GITHUB_REPO}/releases`,
        headers: {
          'user-agent': 'Release Checker'
        }
      }, function (res) {
        let data = ""

        res.on('data', function (chunk) {
          data += chunk
        })

        res.on('error', function (err) {
          throw err
        })

        res.on('end', function () {
          data = JSON.parse(data).filter(function (release) {
            return release.tag_name === pkg.version
          })

          if (data.length > 0) {
            gutil.log(`Release ${pkg.version} already exists. Aboting without error.`)

            process.exit(0)
          }

          const assets = walk(DIR.dist).sort()

          GithubPublisher({
            token: process.env.GITHUB_TOKEN,
            owner: process.env.GITHUB_ACCOUNT,
            repo: process.env.GITHUB_REPO,
            tag: pkg.version,
            name: pkg.version,
            notes: `Releasing v${pkg.version}`,
            draft: false,
            prerelease: false,
            reuseRelease: true,
            reuseDraftOnly: true,
            assets: assets,
            // apiUrl: 'https://myGHEserver/api/v3',
            target_commitish: 'master'
          }, function (err, release) {
            if (err) {
              err.errors.forEach((e) => console.error((`${e.resource} ${e.code}`).red.bold))

              process.exit(1)
            }

            gutil.log(release)
          })
        })
      })
    }
  })
})
<|endoftext|>


<commit_before>( function() {
	'use strict';

	var checkElementDimensions = function( elemConstructor ) {
		var styles;
		var elem;

		beforeEach( function () {
			jasmine.addMatchers(d2l.jasmine.matchers);
			elem = elemConstructor();
			document.body.appendChild(elem);
		});

		it( 'has correct outer height', function() {
			expect( elem.offsetHeight ).toBe( 28 );
		} );

		it( 'has correct inner height', function() {
			expect( elem.clientHeight ).toBe( 26 );
		} );

		it( 'has correct margins' , function() {
			expect( elem ).toHaveTopMargin( '0px' );
			expect( elem ).toHaveBottomMargin( '0px' );
			expect( elem ).toHaveLeftMargin( '0px' );
			expect( elem ).toHaveRightMargin( '0px' );
		} );

		it( 'responds to font change Arial 11', function() {
			document.body.style.fontFamily="Arial";
			document.body.style.fontSize="11px";
			expect( elem.offsetHeight ).toBe( 28 );
		} );

		it( 'responds to font change Arial 13', function() {
			document.body.style.fontFamily="Arial";
			document.body.style.fontSize="13px";
			expect( elem.offsetHeight ).toBe( 28 );
		} );

		it( 'responds to font change Arial 15', function() {
			document.body.style.fontFamily="Arial";
			document.body.style.fontSize="15px";
			expect( elem.offsetHeight ).toBeOnBrowser( { 'default' : 29, 'Firefox' : 31 } );
		} );

		it( 'responds to font change Arial 17', function() {
			document.body.style.fontFamily="Arial";
			document.body.style.fontSize="17px";
			expect( elem.offsetHeight ).toBeOnBrowser( { 'default' : 32, 'Firefox' : 33 } );
		} );

		it( 'responds to font change Verdana 11', function() {
			document.body.style.fontFamily="Verdana";
			document.body.style.fontSize="11px";
			expect( elem.offsetHeight ).toBe( 28 );
		} );

		it( 'responds to font change Verdana 13', function() {
			document.body.style.fontFamily="Verdana";
			document.body.style.fontSize="13px";
			expect( elem.offsetHeight ).toBeOnBrowser( { 'default' : 28, 'Firefox' : 29 } );
		} );

		it( 'responds to font change Verdana 15', function() {
			document.body.style.fontFamily="Verdana";
			document.body.style.fontSize="15px";
			expect( elem.offsetHeight ).toBeOnBrowser( { 'default' : 30, 'Firefox' : 32 } );
		} );

		it( 'responds to font change Verdana 17', function() {
			document.body.style.fontFamily="Verdana";
			document.body.style.fontSize="17px";
			expect( elem.offsetHeight ).toBeOnBrowser( { 'default' : 32, 'Firefox' : 34, 'Chrome' : 33 } );
		} );

		afterEach( function() {
			document.body.removeChild(elem);
		} );
	};

	describe( 'vui-button', function() {

		beforeEach( function() {
			document.body.style.fontFamily="Arial";
			document.body.style.fontSize="13px";
		} );

		var createVUIButton = function( tag ) {
			var vuib = document.createElement( tag );
			vuib.className = 'vui-button';
			return vuib;
		}

		describe ( 'anchor', function() {
			checkElementDimensions(
				function() {
					var anc = createVUIButton( 'a' );
					anc.innerHTML = "test";
					return anc;
				}
			);

			describe( 'vui-disabled', function() {
				checkElementDimensions(
					function() {
						var dis = createVUIButton( 'a' );
						dis.classList.add( 'vui-disabled' );
						dis.innerHTML = "test";
						return dis;
					}
				);
			} );
		} );

		describe ( 'button', function() {
			checkElementDimensions(
				function() {
					var btn = createVUIButton( 'button' );
					btn.innerHTML = "test";
					return btn;
				}
			);

			describe( 'vui-disabled', function() {
				checkElementDimensions(
					function() {
						var dis = createVUIButton( 'button' );
						dis.classList.add( 'vui-disabled' );
						dis.innerHTML = "test";
						return dis;
					}
				);
			} );
		} );

		describe ( 'input', function() {
			checkElementDimensions(
				function() {
					var inp = createVUIButton( 'input' );
					inp.setAttribute("type", "button");
					inp.setAttribute("value", "test");
					return inp;
				}
			);

			describe( 'vui-disabled', function() {
				checkElementDimensions(
					function() {
						var dis = createVUIButton( 'input' );
						dis.setAttribute("type", "button");
						dis.classList.add( 'vui-disabled' );
						dis.setAttribute("value", "test");
						return dis;
					}
				);
			} );
		} );

	} );

} )();<commit_msg>Change check to verify in function signature.<commit_after>( function() {
	'use strict';

	var verifyElementDimensions = function( elemConstructor ) {
		var styles;
		var elem;

		beforeEach( function () {
			jasmine.addMatchers(d2l.jasmine.matchers);
			elem = elemConstructor();
			document.body.appendChild(elem);
		});

		it( 'has correct outer height', function() {
			expect( elem.offsetHeight ).toBe( 28 );
		} );

		it( 'has correct inner height', function() {
			expect( elem.clientHeight ).toBe( 26 );
		} );

		it( 'has correct margins' , function() {
			expect( elem ).toHaveTopMargin( '0px' );
			expect( elem ).toHaveBottomMargin( '0px' );
			expect( elem ).toHaveLeftMargin( '0px' );
			expect( elem ).toHaveRightMargin( '0px' );
		} );

		it( 'responds to font change Arial 11', function() {
			document.body.style.fontFamily="Arial";
			document.body.style.fontSize="11px";
			expect( elem.offsetHeight ).toBe( 28 );
		} );

		it( 'responds to font change Arial 13', function() {
			document.body.style.fontFamily="Arial";
			document.body.style.fontSize="13px";
			expect( elem.offsetHeight ).toBe( 28 );
		} );

		it( 'responds to font change Arial 15', function() {
			document.body.style.fontFamily="Arial";
			document.body.style.fontSize="15px";
			expect( elem.offsetHeight ).toBeOnBrowser( { 'default' : 29, 'Firefox' : 31 } );
		} );

		it( 'responds to font change Arial 17', function() {
			document.body.style.fontFamily="Arial";
			document.body.style.fontSize="17px";
			expect( elem.offsetHeight ).toBeOnBrowser( { 'default' : 32, 'Firefox' : 33 } );
		} );

		it( 'responds to font change Verdana 11', function() {
			document.body.style.fontFamily="Verdana";
			document.body.style.fontSize="11px";
			expect( elem.offsetHeight ).toBe( 28 );
		} );

		it( 'responds to font change Verdana 13', function() {
			document.body.style.fontFamily="Verdana";
			document.body.style.fontSize="13px";
			expect( elem.offsetHeight ).toBeOnBrowser( { 'default' : 28, 'Firefox' : 29 } );
		} );

		it( 'responds to font change Verdana 15', function() {
			document.body.style.fontFamily="Verdana";
			document.body.style.fontSize="15px";
			expect( elem.offsetHeight ).toBeOnBrowser( { 'default' : 30, 'Firefox' : 32 } );
		} );

		it( 'responds to font change Verdana 17', function() {
			document.body.style.fontFamily="Verdana";
			document.body.style.fontSize="17px";
			expect( elem.offsetHeight ).toBeOnBrowser( { 'default' : 32, 'Firefox' : 34, 'Chrome' : 33 } );
		} );

		afterEach( function() {
			document.body.removeChild(elem);
		} );
	};

	describe( 'vui-button', function() {

		beforeEach( function() {
			document.body.style.fontFamily="Arial";
			document.body.style.fontSize="13px";
		} );

		var createVUIButton = function( tag ) {
			var vuib = document.createElement( tag );
			vuib.className = 'vui-button';
			return vuib;
		}

		describe ( 'anchor', function() {
			verifyElementDimensions(
				function() {
					var anc = createVUIButton( 'a' );
					anc.innerHTML = "test";
					return anc;
				}
			);

			describe( 'vui-disabled', function() {
				verifyElementDimensions(
					function() {
						var dis = createVUIButton( 'a' );
						dis.classList.add( 'vui-disabled' );
						dis.innerHTML = "test";
						return dis;
					}
				);
			} );
		} );

		describe ( 'button', function() {
			verifyElementDimensions(
				function() {
					var btn = createVUIButton( 'button' );
					btn.innerHTML = "test";
					return btn;
				}
			);

			describe( 'vui-disabled', function() {
				verifyElementDimensions(
					function() {
						var dis = createVUIButton( 'button' );
						dis.classList.add( 'vui-disabled' );
						dis.innerHTML = "test";
						return dis;
					}
				);
			} );
		} );

		describe ( 'input', function() {
			verifyElementDimensions(
				function() {
					var inp = createVUIButton( 'input' );
					inp.setAttribute("type", "button");
					inp.setAttribute("value", "test");
					return inp;
				}
			);

			describe( 'vui-disabled', function() {
				verifyElementDimensions(
					function() {
						var dis = createVUIButton( 'input' );
						dis.setAttribute("type", "button");
						dis.classList.add( 'vui-disabled' );
						dis.setAttribute("value", "test");
						return dis;
					}
				);
			} );
		} );

	} );

} )();<|endoftext|>


<commit_before>require('events').EventEmitter.defaultMaxListeners = 30;

var cssnext = require('postcss-cssnext');
var elixir = require('laravel-elixir');
var gutils = require('gulp-util');

elixir.config.js.browserify.transformers.push({
    name: 'vueify',

    options: {
        postcss: [cssnext()]
    }
});

if (gutils.env._.indexOf('watch') > -1) {
    elixir.config.js.browserify.plugins.push({
        name: "browserify-hmr",
        options : {}
    });
}

elixir(function (mix) {
    mix.browserify('main.js');
    mix.sass('app.scss');

    mix.copy('resources/assets/img', 'public/img')
        .copy('node_modules/font-awesome/fonts', 'public/build/fonts')
        .copy('resources/assets/fonts', 'public/build/fonts');

    mix.scripts([
            'node_modules/babel-polyfill/dist/polyfill.min.js',
            'node_modules/plyr/dist/plyr.js',
            'node_modules/rangetouch/dist/rangetouch.js',
            'resources/assets/js/libs/modernizr-custom.js'
        ], 'public/js/vendors.js', './')
        .styles([
            'resources/assets/css/**/*.css',
            'node_modules/font-awesome/css/font-awesome.min.css',
            'node_modules/rangeslider.js/dist/rangeslider.css'
        ], 'public/css/vendors.css', './');

    mix.version(['css/vendors.css', 'css/app.css', 'js/vendors.js', 'js/main.js']);

    if (process.env.NODE_ENV !== 'production') {
        mix.browserSync({
            proxy: 'koel.dev',
            files: [
                elixir.config.get('public.css.outputFolder') + '/**/*.css',
                elixir.config.get('public.versioning.buildFolder') + '/rev-manifest.json',
            ]
        });
    }
});
<commit_msg>Fix tabwidth for gulpfile<commit_after>require('events').EventEmitter.defaultMaxListeners = 30;

var cssnext = require('postcss-cssnext');
var elixir = require('laravel-elixir');
var gutils = require('gulp-util');

elixir.config.js.browserify.transformers.push({
  name: 'vueify',

  options: {
    postcss: [cssnext()]
  }
});

if (gutils.env._.indexOf('watch') > -1) {
  elixir.config.js.browserify.plugins.push({
    name: "browserify-hmr",
    options : {}
  });
}

elixir(function (mix) {
  mix.browserify('main.js');
  mix.sass('app.scss');

  mix.copy('resources/assets/img', 'public/img')
    .copy('node_modules/font-awesome/fonts', 'public/build/fonts')
    .copy('resources/assets/fonts', 'public/build/fonts');

  mix.scripts([
      'node_modules/babel-polyfill/dist/polyfill.min.js',
      'node_modules/plyr/dist/plyr.js',
      'node_modules/rangetouch/dist/rangetouch.js',
      'resources/assets/js/libs/modernizr-custom.js'
    ], 'public/js/vendors.js', './')
    .styles([
      'resources/assets/css/**/*.css',
      'node_modules/font-awesome/css/font-awesome.min.css',
      'node_modules/rangeslider.js/dist/rangeslider.css'
    ], 'public/css/vendors.css', './');

  mix.version(['css/vendors.css', 'css/app.css', 'js/vendors.js', 'js/main.js']);

  if (process.env.NODE_ENV !== 'production') {
    mix.browserSync({
      proxy: 'koel.dev',
      files: [
        elixir.config.get('public.css.outputFolder') + '/**/*.css',
        elixir.config.get('public.versioning.buildFolder') + '/rev-manifest.json',
      ]
    });
  }
});
<|endoftext|>


<commit_before>import { assert } from 'chai';
import CipherService from '../../src/index';
import JwtCipher from '../../src/JwtCipher';

describe('CipherService', () => {
  it('Should properly export', () => {
    assert.isFunction(CipherService);
  });

  it('Should properly create JWT cipher', () => {
    let cipher = CipherService('jwt');
    assert.instanceOf(cipher, JwtCipher);
  });

  it('Should properly encode/decode data', () => {
    let cipher = CipherService('jwt');
    assert.typeOf(cipher.encodeSync('test'), 'string');
  });

  it('Should properly throw error if type is unrecognized', () => {
    assert.throw(() => CipherService.create('NOT_EXISTS'), Error);
  });
});
<commit_msg>Improve test coverage<commit_after>import { assert } from 'chai';
import CipherService from '../../src/index';
import JwtCipher from '../../src/JwtCipher';

describe('CipherService', () => {
  it('Should properly export', () => {
    assert.isFunction(CipherService);
  });

  it('Should properly create JWT cipher', () => {
    let cipher = CipherService('jwt');
    assert.instanceOf(cipher, JwtCipher);
  });

  it('Should properly encode/decode data', () => {
    let cipher = CipherService('jwt');
    assert.typeOf(cipher.encodeSync('test'), 'string');
  });

  it('Should properly throw error if type is unrecognized', () => {
    assert.throw(() => CipherService('NOT_EXISTS'), Error);
  });
});
<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp'),
    g = require('gulp-load-plugins')({lazy: false}),
    noop = g.util.noop,
    es = require('event-stream'),
    bowerFiles = require('main-bower-files'),
    rimraf = require('rimraf'),
    queue = require('streamqueue'),
    lazypipe = require('lazypipe'),
    bower = require('./bower'),
    runSequence = require('run-sequence'),
    isWatching = false;

var htmlminOpts = {
  removeComments: true,
  collapseWhitespace: true,
  removeEmptyAttributes: false,
  collapseBooleanAttributes: true
};

/**
 * Base url in config.js
 */
var _baseUrlEnvMapping = {
	local: "localhost:5000",
	test: "devapi.dbs.bh.org.il",
	live: "api.dbs.bh.org.il"
};

gulp.task('base-url', function() {
  var apiServer = process.env.API_SERVER || 'test';

  return gulp.src('./js/modules/config/config.js')
    .pipe(g.replace('BaseUrlPlaceHolder', _baseUrlEnvMapping[apiServer]))
    .pipe(gulp.dest('./.tmp/'));
});

/**
 * CSS
 */
gulp.task('clean-css', function (done) {
  rimraf('./.tmp/css', done);
});

gulp.task('styles', ['clean-css'], function () {
  return gulp.src([
    './scss/**/*.scss',
    '!./scss/**/_*.scss'
  ])
    .pipe(g.sourcemaps.init())
    .pipe(g.sass().on('error', g.sass.logError))
    .pipe(g.autoprefixer({browsers: ['last 2 versions', '> 2%']}))
    .pipe(g.sourcemaps.write('./'))
    .pipe(gulp.dest('./.tmp/css/'))
    .pipe(g.cached('built-css'))
    .pipe(livereload());
});

gulp.task('styles-dist', ['styles'], function () {
  return cssFiles().pipe(dist('css', bower.name));
});

/**
 * Scripts
 */
gulp.task('scripts-dist', ['templates-dist'], function () {
  return appFiles().pipe(dist('js', bower.name, {ngAnnotate: true}));
});

/**
 * Templates
 */
gulp.task('templates', function () {
  return templateFiles().pipe(buildTemplates());
});

gulp.task('templates-dist', function () {
  return templateFiles({min: true}).pipe(buildTemplates());
});

/**
 * Vendors
 */
gulp.task('vendors', function () {
  var bowerStream = gulp.src(bowerFiles());
  return es.merge(
    bowerStream.pipe(g.filter('**/*.css')).pipe(dist('css', 'vendors')),
    bowerStream.pipe(g.filter('**/*.js')).pipe(dist('js', 'vendors'))
  );
});

/**
 * Index
 */
gulp.task('index', index);
gulp.task('build-all', ['styles', 'templates', 'base-url'], index);

function index () {
  var opt = {read: false};
  return gulp.src('./index.html')
    .pipe(g.inject(gulp.src(bowerFiles(), opt), {ignorePath: 'bower_components', starttag: '<!-- inject:vendor:{{ext}} -->'}))
    .pipe(g.inject(es.merge(appFiles(), cssFiles(opt)), {ignorePath: ['.tmp']}))
    .pipe(gulp.dest('.'))
    .pipe(g.embedlr())
    .pipe(gulp.dest('./.tmp/'))
    .pipe(livereload());
}

/**
 * Static assets
 */

gulp.task('fonts', function () {
  return gulp.src('./fonts/**')
    .pipe(gulp.dest('./dist/fonts'));
});

gulp.task('images', function () {
  return gulp.src('./images/**')
    .pipe(gulp.dest('./dist/images'));
});

gulp.task('assets', ['fonts', 'images']);

/**
 * Dist
 */
gulp.task('dist-clean', function (done) {
  rimraf('./dist', done);
});

gulp.task('dist-index', function() {
  return gulp.src('./index.html')
    .pipe(g.inject(gulp.src('./dist/{js,css}/vendors*.min.{js,css}'), {ignorePath: 'dist', starttag: '<!-- inject:vendor:{{ext}} -->', addRootSlash:false}))
    .pipe(g.inject(gulp.src('./dist/{js,css}/' + bower.name + '*.min.{js,css}'), {ignorePath: 'dist', addRootSlash:false}))
    .pipe(g.htmlmin(htmlminOpts))
    .pipe(gulp.dest('./dist/'));
});

gulp.task('dist', function (cb) {
  runSequence(
    'dist-clean',
    ['base-url', 'vendors', 'assets', 'styles-dist', 'scripts-dist'],
    'dist-index',
    cb
  );
});

/**
 * Static file server
 */
gulp.task('connect', function() {

  g.connect.server({
    port: 3000,
    root: ['./.tmp', './', './bower_components'],
    fallback: './index.html',
    middleware: function() {
      return [
        // place required middleware here
      ];
    }
  });
});

gulp.task('serve:dist', function() {

  g.connect.server({
    port: 3000,
    root: ['./dist'],
    fallback: './dist/index.html',
    middleware: function() {
      return [
        // place required middleware here
      ];
    }
  });
});

/**
 * Watch
 */
gulp.task('serve', ['watch']);
gulp.task('watch', ['connect', 'default'], function () {
  isWatching = true;
  // Initiate livereload server:
  g.livereload.listen();
  gulp.watch('./js/**/*.js').on('change', function (evt) {
    if (evt.type !== 'changed') {
      gulp.start('index');
    } else {
      g.livereload.changed(evt);
    }
  });
  gulp.watch('./index.html', ['index']);
  gulp.watch(['./templates/**/*.html'], ['templates']);
  gulp.watch(['./scss/**/*.scss']).on('change', function (evt) {
    if (evt.type !== 'changed') {
      gulp.start('index');
    } else {
      gulp.start('styles');
    }
  });
});

/**
 * Default task
 */
gulp.task('default', ['build-all']);

/**
 * Test
 */
gulp.task('test', ['templates', 'base-url'], function () {
  return testFiles()
    .pipe(g.karma({
      configFile: 'js/test/karma.conf.js',
      action: 'run'
    }));
});

/**
 * Inject all files for tests into karma.conf.js
 * to be able to run `karma` without gulp.
 */
gulp.task('karma-conf', ['templates', 'base-url'], function () {
  return gulp.src('./js/test/karma.conf.js')
    .pipe(g.inject(testFiles(), {
      starttag: 'files: [',
      endtag: ']',
      addRootSlash: false,
      transform: function (filepath, file, i, length) {
        return '  \'' + filepath + '\'' + (i + 1 < length ? ',' : '');
      }
    }))
    .pipe(gulp.dest('./js/test/'));
});

/**
 * Test files
 */
function testFiles() {
  return new queue({objectMode: true})
    .queue(gulp.src('./bower_components/jquery/dist/jquery.js'))
    .queue(gulp.src('./bower_components/angular/angular.js'))
    .queue(gulp.src(bowerFiles()).pipe(g.filter('**/*.js')))
    .queue(gulp.src('./bower_components/angular-mocks/angular-mocks.js'))
    .queue(appFiles())
    .queue(gulp.src(['./js/**/*Spec.js', './.tmp/js/**/*Spec.js']))
    .done();
}

/**
 * All CSS files as a stream
 */
function cssFiles (opt) {
  return gulp.src('./.tmp/css/**/*.css', opt);
}

/**
 * All AngularJS application files as a stream
 */
function appFiles () {
  var files = [
    './.tmp/' + bower.name + '-templates.js',
    './.tmp/config.js',
    './js/**/*.js',
    '!./js/**/*Spec.js',
    '!./js/modules/config/**',
    '!./js/test/**',
    '!./js/modules/main/test/**'
  ];
  return gulp.src(files)
    .pipe(g.naturalSort())
    .pipe(g.angularFilesort());
}

/**
 * All AngularJS templates/partials as a stream
 */
function templateFiles (opt) {
  return gulp.src(['./templates/**/*.html'], opt)
    .pipe(opt && opt.min ? g.htmlmin(htmlminOpts) : noop());
}

/**
 * Build AngularJS templates/partials
 */
function buildTemplates () {
  return lazypipe()
    .pipe(g.ngHtml2js, {
      moduleName: bower.name + '-templates',
      /*prefix: '/' + bower.name + '/',*/
      prefix: 'templates/'
    })
    .pipe(g.concat, bower.name + '-templates.js')
    .pipe(gulp.dest, './.tmp')
    .pipe(livereload)();
}

/**
 * Concat, rename, minify
 *
 * @param {String} ext
 * @param {String} name
 * @param {Object} opt
 */
function dist (ext, name, opt) {
  opt = opt || {};
  var stamp = new Date().getTime();
  return lazypipe()
    .pipe(g.concat, name + '.' + ext)
    // .pipe(gulp.dest, './dist/' + ext + '/')
    // .pipe(opt.ngAnnotate ? g.ngAnnotate : noop)
    // .pipe(opt.ngAnnotate ? g.rename : noop, name + '.annotated.' + ext)
    // .pipe(opt.ngAnnotate ? gulp.dest : noop, './dist/' + ext)
    .pipe(ext === 'js' ? g.uglify : g.minifyCss)
    .pipe(g.rename, name + '-' + stamp + '.min.' + ext)
    .pipe(gulp.dest, './dist/' + ext + '/')();
}

/**
 * Livereload (or noop if not run by watch)
 */
function livereload () {
  return lazypipe()
    .pipe(isWatching ? g.livereload : noop)();
}
<commit_msg>fixing html minification<commit_after>'use strict';

var gulp = require('gulp'),
    g = require('gulp-load-plugins')({lazy: false}),
    noop = g.util.noop,
    es = require('event-stream'),
    bowerFiles = require('main-bower-files'),
    rimraf = require('rimraf'),
    queue = require('streamqueue'),
    lazypipe = require('lazypipe'),
    bower = require('./bower'),
    runSequence = require('run-sequence'),
    isWatching = false;

var htmlminOpts = {
  removeComments: true,
  /*collapseWhitespace: true,*/
  removeEmptyAttributes: false,
  collapseBooleanAttributes: true
};

/**
 * Base url in config.js
 */
var _baseUrlEnvMapping = {
	local: "localhost:5000",
	test: "devapi.dbs.bh.org.il",
	live: "api.dbs.bh.org.il"
};

gulp.task('base-url', function() {
  var apiServer = process.env.API_SERVER || 'test';

  return gulp.src('./js/modules/config/config.js')
    .pipe(g.replace('BaseUrlPlaceHolder', _baseUrlEnvMapping[apiServer]))
    .pipe(gulp.dest('./.tmp/'));
});

/**
 * CSS
 */
gulp.task('clean-css', function (done) {
  rimraf('./.tmp/css', done);
});

gulp.task('styles', ['clean-css'], function () {
  return gulp.src([
    './scss/**/*.scss',
    '!./scss/**/_*.scss'
  ])
    .pipe(g.sourcemaps.init())
    .pipe(g.sass().on('error', g.sass.logError))
    .pipe(g.autoprefixer({browsers: ['last 2 versions', '> 2%']}))
    .pipe(g.sourcemaps.write('./'))
    .pipe(gulp.dest('./.tmp/css/'))
    .pipe(g.cached('built-css'))
    .pipe(livereload());
});

gulp.task('styles-dist', ['styles'], function () {
  return cssFiles().pipe(dist('css', bower.name));
});

/**
 * Scripts
 */
gulp.task('scripts-dist', ['templates-dist'], function () {
  return appFiles().pipe(dist('js', bower.name, {ngAnnotate: true}));
});

/**
 * Templates
 */
gulp.task('templates', function () {
  return templateFiles().pipe(buildTemplates());
});

gulp.task('templates-dist', function () {
  return templateFiles({min: true}).pipe(buildTemplates());
});

/**
 * Vendors
 */
gulp.task('vendors', function () {
  var bowerStream = gulp.src(bowerFiles());
  return es.merge(
    bowerStream.pipe(g.filter('**/*.css')).pipe(dist('css', 'vendors')),
    bowerStream.pipe(g.filter('**/*.js')).pipe(dist('js', 'vendors'))
  );
});

/**
 * Index
 */
gulp.task('index', index);
gulp.task('build-all', ['styles', 'templates', 'base-url'], index);

function index () {
  var opt = {read: false};
  return gulp.src('./index.html')
    .pipe(g.inject(gulp.src(bowerFiles(), opt), {ignorePath: 'bower_components', starttag: '<!-- inject:vendor:{{ext}} -->'}))
    .pipe(g.inject(es.merge(appFiles(), cssFiles(opt)), {ignorePath: ['.tmp']}))
    .pipe(gulp.dest('.'))
    .pipe(g.embedlr())
    .pipe(gulp.dest('./.tmp/'))
    .pipe(livereload());
}

/**
 * Static assets
 */

gulp.task('fonts', function () {
  return gulp.src('./fonts/**')
    .pipe(gulp.dest('./dist/fonts'));
});

gulp.task('images', function () {
  return gulp.src('./images/**')
    .pipe(gulp.dest('./dist/images'));
});

gulp.task('assets', ['fonts', 'images']);

/**
 * Dist
 */
gulp.task('dist-clean', function (done) {
  rimraf('./dist', done);
});

gulp.task('dist-index', function() {
  return gulp.src('./index.html')
    .pipe(g.inject(gulp.src('./dist/{js,css}/vendors*.min.{js,css}'), {ignorePath: 'dist', starttag: '<!-- inject:vendor:{{ext}} -->', addRootSlash:false}))
    .pipe(g.inject(gulp.src('./dist/{js,css}/' + bower.name + '*.min.{js,css}'), {ignorePath: 'dist', addRootSlash:false}))
    .pipe(g.htmlmin(htmlminOpts))
    .pipe(gulp.dest('./dist/'));
});

gulp.task('dist', function (cb) {
  runSequence(
    'dist-clean',
    ['base-url', 'vendors', 'assets', 'styles-dist', 'scripts-dist'],
    'dist-index',
    cb
  );
});

/**
 * Static file server
 */
gulp.task('connect', function() {

  g.connect.server({
    port: 3000,
    root: ['./.tmp', './', './bower_components'],
    fallback: './index.html',
    middleware: function() {
      return [
        // place required middleware here
      ];
    }
  });
});

gulp.task('serve:dist', function() {

  g.connect.server({
    port: 3000,
    root: ['./dist'],
    fallback: './dist/index.html',
    middleware: function() {
      return [
        // place required middleware here
      ];
    }
  });
});

/**
 * Watch
 */
gulp.task('serve', ['watch']);
gulp.task('watch', ['connect', 'default'], function () {
  isWatching = true;
  // Initiate livereload server:
  g.livereload.listen();
  gulp.watch('./js/**/*.js').on('change', function (evt) {
    if (evt.type !== 'changed') {
      gulp.start('index');
    } else {
      g.livereload.changed(evt);
    }
  });
  gulp.watch('./index.html', ['index']);
  gulp.watch(['./templates/**/*.html'], ['templates']);
  gulp.watch(['./scss/**/*.scss']).on('change', function (evt) {
    if (evt.type !== 'changed') {
      gulp.start('index');
    } else {
      gulp.start('styles');
    }
  });
});

/**
 * Default task
 */
gulp.task('default', ['build-all']);

/**
 * Test
 */
gulp.task('test', ['templates', 'base-url'], function () {
  return testFiles()
    .pipe(g.karma({
      configFile: 'js/test/karma.conf.js',
      action: 'run'
    }));
});

/**
 * Inject all files for tests into karma.conf.js
 * to be able to run `karma` without gulp.
 */
gulp.task('karma-conf', ['templates', 'base-url'], function () {
  return gulp.src('./js/test/karma.conf.js')
    .pipe(g.inject(testFiles(), {
      starttag: 'files: [',
      endtag: ']',
      addRootSlash: false,
      transform: function (filepath, file, i, length) {
        return '  \'' + filepath + '\'' + (i + 1 < length ? ',' : '');
      }
    }))
    .pipe(gulp.dest('./js/test/'));
});

/**
 * Test files
 */
function testFiles() {
  return new queue({objectMode: true})
    .queue(gulp.src('./bower_components/jquery/dist/jquery.js'))
    .queue(gulp.src('./bower_components/angular/angular.js'))
    .queue(gulp.src(bowerFiles()).pipe(g.filter('**/*.js')))
    .queue(gulp.src('./bower_components/angular-mocks/angular-mocks.js'))
    .queue(appFiles())
    .queue(gulp.src(['./js/**/*Spec.js', './.tmp/js/**/*Spec.js']))
    .done();
}

/**
 * All CSS files as a stream
 */
function cssFiles (opt) {
  return gulp.src('./.tmp/css/**/*.css', opt);
}

/**
 * All AngularJS application files as a stream
 */
function appFiles () {
  var files = [
    './.tmp/' + bower.name + '-templates.js',
    './.tmp/config.js',
    './js/**/*.js',
    '!./js/**/*Spec.js',
    '!./js/modules/config/**',
    '!./js/test/**',
    '!./js/modules/main/test/**'
  ];
  return gulp.src(files)
    .pipe(g.naturalSort())
    .pipe(g.angularFilesort());
}

/**
 * All AngularJS templates/partials as a stream
 */
function templateFiles (opt) {
  return gulp.src(['./templates/**/*.html'], opt)
    .pipe(opt && opt.min ? g.htmlmin(htmlminOpts) : noop());
}

/**
 * Build AngularJS templates/partials
 */
function buildTemplates () {
  return lazypipe()
    .pipe(g.ngHtml2js, {
      moduleName: bower.name + '-templates',
      /*prefix: '/' + bower.name + '/',*/
      prefix: 'templates/'
    })
    .pipe(g.concat, bower.name + '-templates.js')
    .pipe(gulp.dest, './.tmp')
    .pipe(livereload)();
}

/**
 * Concat, rename, minify
 *
 * @param {String} ext
 * @param {String} name
 * @param {Object} opt
 */
function dist (ext, name, opt) {
  opt = opt || {};
  var stamp = new Date().getTime();
  return lazypipe()
    .pipe(g.concat, name + '.' + ext)
    // .pipe(gulp.dest, './dist/' + ext + '/')
    // .pipe(opt.ngAnnotate ? g.ngAnnotate : noop)
    // .pipe(opt.ngAnnotate ? g.rename : noop, name + '.annotated.' + ext)
    // .pipe(opt.ngAnnotate ? gulp.dest : noop, './dist/' + ext)
    .pipe(ext === 'js' ? g.uglify : g.minifyCss)
    .pipe(g.rename, name + '-' + stamp + '.min.' + ext)
    .pipe(gulp.dest, './dist/' + ext + '/')();
}

/**
 * Livereload (or noop if not run by watch)
 */
function livereload () {
  return lazypipe()
    .pipe(isWatching ? g.livereload : noop)();
}
<|endoftext|>


<commit_before>/*jslint white: true*/
/*global module */
// process.env.CHROME_BIN = require('puppeteer').executablePath();
module.exports = function (config) {
    'use strict';
    config.set({
        basePath: '../../',
        frameworks: ['jasmine', 'requirejs', 'es6-shim'],
        client: {
            jasmine: {
                failFast: false,
                DEFAULT_TIMEOUT_INTERVAL: 20000
            },
            requireJsShowNoTimestampsError: '^(?!.*(^/narrative/static/))',
            clearContext: false
        },
        plugins: [
            'karma-jasmine',
            'karma-chrome-launcher',
            'karma-firefox-launcher',
            'karma-phantomjs-launcher',
            'karma-requirejs',
            'karma-coverage',
            'karma-mocha-reporter',
            'karma-es6-shim'
        ],
        preprocessors: {
            'kbase-extension/static/kbase/js/**/!(api)/*.js': ['coverage'],
            'kbase-extension/static/kbase/js/api/!(*[Cc]lient*|Catalog|KBaseFeatureValues|NarrativeJobServiceWrapper|NewWorkspace)*.js': ['coverage'],
            'kbase-extension/static/kbase/js/api/RestAPIClient.js': ['coverage'],
            'nbextensions/appcell2/widgets/tabs/*.js': ['coverage'],
        },
        files: [
            'kbase-extension/static/narrative_paths.js',
            //{pattern: 'test/unit/spec/**/*.js', included: false},
            {pattern: 'test/unit/spec/narrative_core/kbaseNarrativeDataList-spec.js', included: false},
            {pattern: 'node_modules/jasmine-ajax/lib/mock-ajax.js', included: true},
            {pattern: 'kbase-extension/static/ext_components/kbase-ui-plugin-catalog/src/plugin/modules/data/categories.yml', included: false, served: true},
            {pattern: 'kbase-extension/static/**/*.css', included: false, served: true},
            {pattern: 'kbase-extension/static/kbase/templates/**/*.html', included: false, served: true},
            {pattern: 'kbase-extension/static/kbase/config/**/*.json', included: false, served: true},
            {pattern: 'kbase-extension/static/kbase/config/**/*.yaml', included: false, served: true},
            {pattern: 'kbase-extension/static/**/*.js', included: false, served: true},
            {pattern: 'kbase-extension/static/**/*.gif', included: false, served: true},
            {pattern: 'nbextensions/appcell2/widgets/tabs/*.js', included: false},
            {pattern: 'test/unit/testConfig.json', included: false, served: true, nocache: true},
            {pattern: 'test/*.tok', included: false, served: true, nocache: true},
            {pattern: 'test/data/**/*', included: false, served: true},
            'test/unit/testUtil.js',
            'test/unit/test-main.js'
        ],
        exclude: [
            'kbase-extension/static/buildTools/*.js',
            'kbase-extension/static/ext_components/**/test/**/*.js',
            'kbase-extension/static/kbase/js/patched-components/**/*'
        ],
        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['mocha', 'coverage'],
        coverageReporter: {
            type: 'html',
            dir: 'js-coverage/',
            reporters: [{
                type: 'html',
                subdir: 'html'
            }, {
                type: 'lcov',
                subdir: 'lcov'
            }],
            includeAllSources: true
        },
        mochaReporter: {
            ignoreSkipped: true,
        },
        // web server port
        port: 9876,
        // enable / disable colors in the output (reporters and logs)
        colors: true,
        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,
        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: false,
        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        browsers: ['ChromeHeadless'],
        browserNoActivityTimeout: 30000,
        singleRun: true,
        proxies: {
            '/narrative/nbextensions': 'http://localhost:32323/narrative/nbextensions',
            '/narrative/static/': '/base/kbase-extension/static/',
            '/narrative/static/base': 'http://localhost:32323/narrative/static/base',
            '/narrative/static/notebook': 'http://localhost:32323/narrative/static/notebook',
            '/narrative/static/components': 'http://localhost:32323/narrative/static/components',
            '/narrative/static/services': 'http://localhost:32323/narrative/static/services',
            '/narrative/static/bidi': 'http://localhost:32323/narrative/static/bidi',
            '/static/kbase/config': '/base/kbase-extension/static/kbase/config',
            '/test/': '/base/test/'
        },
        concurrency: Infinity

    });
};
<commit_msg>Fix karma conf<commit_after>/*jslint white: true*/
/*global module */
// process.env.CHROME_BIN = require('puppeteer').executablePath();
module.exports = function (config) {
    'use strict';
    config.set({
        basePath: '../../',
        frameworks: ['jasmine', 'requirejs', 'es6-shim'],
        client: {
            jasmine: {
                failFast: false,
                DEFAULT_TIMEOUT_INTERVAL: 20000
            },
            requireJsShowNoTimestampsError: '^(?!.*(^/narrative/static/))',
            clearContext: false
        },
        plugins: [
            'karma-jasmine',
            'karma-chrome-launcher',
            'karma-firefox-launcher',
            'karma-phantomjs-launcher',
            'karma-requirejs',
            'karma-coverage',
            'karma-mocha-reporter',
            'karma-es6-shim'
        ],
        preprocessors: {
            'kbase-extension/static/kbase/js/**/!(api)/*.js': ['coverage'],
            'kbase-extension/static/kbase/js/api/!(*[Cc]lient*|Catalog|KBaseFeatureValues|NarrativeJobServiceWrapper|NewWorkspace)*.js': ['coverage'],
            'kbase-extension/static/kbase/js/api/RestAPIClient.js': ['coverage'],
            'nbextensions/appcell2/widgets/tabs/*.js': ['coverage'],
        },
        files: [
            'kbase-extension/static/narrative_paths.js',
            {pattern: 'test/unit/spec/**/*.js', included: false},
            {pattern: 'node_modules/jasmine-ajax/lib/mock-ajax.js', included: true},
            {pattern: 'kbase-extension/static/ext_components/kbase-ui-plugin-catalog/src/plugin/modules/data/categories.yml', included: false, served: true},
            {pattern: 'kbase-extension/static/**/*.css', included: false, served: true},
            {pattern: 'kbase-extension/static/kbase/templates/**/*.html', included: false, served: true},
            {pattern: 'kbase-extension/static/kbase/config/**/*.json', included: false, served: true},
            {pattern: 'kbase-extension/static/kbase/config/**/*.yaml', included: false, served: true},
            {pattern: 'kbase-extension/static/**/*.js', included: false, served: true},
            {pattern: 'kbase-extension/static/**/*.gif', included: false, served: true},
            {pattern: 'nbextensions/appcell2/widgets/tabs/*.js', included: false},
            {pattern: 'test/unit/testConfig.json', included: false, served: true, nocache: true},
            {pattern: 'test/*.tok', included: false, served: true, nocache: true},
            {pattern: 'test/data/**/*', included: false, served: true},
            'test/unit/testUtil.js',
            'test/unit/test-main.js'
        ],
        exclude: [
            'kbase-extension/static/buildTools/*.js',
            'kbase-extension/static/ext_components/**/test/**/*.js',
            'kbase-extension/static/kbase/js/patched-components/**/*'
        ],
        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['mocha', 'coverage'],
        coverageReporter: {
            type: 'html',
            dir: 'js-coverage/',
            reporters: [{
                type: 'html',
                subdir: 'html'
            }, {
                type: 'lcov',
                subdir: 'lcov'
            }],
            includeAllSources: true
        },
        mochaReporter: {
            ignoreSkipped: true,
        },
        // web server port
        port: 9876,
        // enable / disable colors in the output (reporters and logs)
        colors: true,
        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,
        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: false,
        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        browsers: ['ChromeHeadless'],
        browserNoActivityTimeout: 30000,
        singleRun: true,
        proxies: {
            '/narrative/nbextensions': 'http://localhost:32323/narrative/nbextensions',
            '/narrative/static/': '/base/kbase-extension/static/',
            '/narrative/static/base': 'http://localhost:32323/narrative/static/base',
            '/narrative/static/notebook': 'http://localhost:32323/narrative/static/notebook',
            '/narrative/static/components': 'http://localhost:32323/narrative/static/components',
            '/narrative/static/services': 'http://localhost:32323/narrative/static/services',
            '/narrative/static/bidi': 'http://localhost:32323/narrative/static/bidi',
            '/static/kbase/config': '/base/kbase-extension/static/kbase/config',
            '/test/': '/base/test/'
        },
        concurrency: Infinity

    });
};
<|endoftext|>


<commit_before>var gulp = require('gulp'),
	path = require('path'),
	jshintReporter = require('jshint-stylish'),
	karma = require('karma').server,
	plugins = require('gulp-load-plugins')({
		config: path.join(__dirname, 'package.json')
	});

var pkg = require('./package.json'),
	header = ['/**',
		' * <%= pkg.name %>',
		' * <%= pkg.description %>',
		' * @version v<%= pkg.version %>',
		' * @link <%= pkg.homepage %>',
		' * @license <%= pkg.license %>',
		' */',
		'(function (angular) {',
		'',
		''
	].join('\n'),
	footer = [
		'',
		'})(angular);',
		''
	].join('\n');

var path = {
	src: {
		files: ['src/**/*.js'],
		jshint: ['src/**/*.js', '!src/**/*.spec.js'],
		e2e: ['src/**/*.spec.js']
	}
};

var commonBuild = {
	libs: [
		'bower_components/string-mask/src/string-mask.js',
	],
	files: [
		'src/global/**/*.js',
		'src/*.js'
	]
};

var builds = {
	br: [
		'bower_components/br-validations/releases/br-validations.js',
		'src/br/**/*.js'
	],
	us: [
		'src/us/**/*.js'
	],
};

function customBuild(files, buildName) {
	var buildFilename = 'angular-input-masks';

	if (buildName) {
		buildFilename += '.' + buildName;
	}

	var buildFiles = commonBuild.libs.concat(files).concat(commonBuild.files);

	return function() {
		return gulp.src(buildFiles)
			.pipe(filterNonCodeFiles())
			.pipe(plugins.concat(buildFilename + '.js'))
			.pipe(plugins.header(header, {pkg: pkg}))
			.pipe(plugins.footer(footer))
			.pipe(gulp.dest('./releases/'))
			.pipe(plugins.uglify())
			.pipe(plugins.concat(buildFilename + '.min.js'))
			.pipe(gulp.dest('./releases/'));
	};
}

var buildTasks = [];
var fullBuildFiles = [];
Object.keys(builds).forEach(function(buildName) {
	var taskName = 'build:' + buildName;
	var buildFiles = builds[buildName];
	gulp.task(taskName, customBuild(buildFiles, buildName));
	buildTasks.push(taskName);
	fullBuildFiles = fullBuildFiles.concat(buildFiles);
});

gulp.task('build', buildTasks, customBuild(fullBuildFiles));

gulp.task('jshint', function() {
	gulp.src(path.src.jshint)
	.pipe(plugins.jshint('.jshintrc'))
	.pipe(plugins.jshint.reporter(jshintReporter));
});

gulp.task('default', ['jshint', 'build'], function() {
	gulp.watch(path.src.files, ['jshint', 'build']);
});

gulp.task('serve', ['build'], function() {
	var express = require('express');
	var server = express();

	server.use(express.static('./'));
	server.listen(8000, function() {
		console.log('Server running in port 8000');
	});
});

gulp.task('test:unit', function(done) {
	var karmaConfig = {
		singleRun: true,
		configFile: __dirname + '/config/karma.conf.js'
	};

	karma.start(karmaConfig, done);
});

gulp.task('test-watch', function(done) {
	var karmaConfig = {
		singleRun: false,
		autoWatch: true,
		configFile: __dirname + '/config/karma.conf.js'
	};

	karma.start(karmaConfig, done);
});

gulp.task('webdriver_update', require('gulp-protractor').webdriver_update);

gulp.task('test:e2e', ['webdriver_update', 'serve'], function() {
	var protractor = require('gulp-protractor').protractor;

	gulp.src(path.src.e2e)
	.pipe(protractor({
		configFile: 'config/protractor.conf.js'
	}))
	.pipe(plugins.exit());
});

gulp.task('test', ['test:unit', 'test:e2e']);

function filterNonCodeFiles() {
	return plugins.filter(function(file) {
		return !/\.json$|\.spec\.js$|\.test\.js$/.test(file.path);
	});
}
<commit_msg>chore: fail jshint before running the tests<commit_after>var gulp = require('gulp'),
	path = require('path'),
	jshintReporter = require('jshint-stylish'),
	karma = require('karma').server,
	plugins = require('gulp-load-plugins')({
		config: path.join(__dirname, 'package.json')
	});

var pkg = require('./package.json'),
	header = ['/**',
		' * <%= pkg.name %>',
		' * <%= pkg.description %>',
		' * @version v<%= pkg.version %>',
		' * @link <%= pkg.homepage %>',
		' * @license <%= pkg.license %>',
		' */',
		'(function (angular) {',
		'',
		''
	].join('\n'),
	footer = [
		'',
		'})(angular);',
		''
	].join('\n');

var path = {
	src: {
		files: ['src/**/*.js'],
		jshint: ['src/**/*.js', '!src/**/*.spec.js'],
		e2e: ['src/**/*.spec.js']
	}
};

var commonBuild = {
	libs: [
		'bower_components/string-mask/src/string-mask.js',
	],
	files: [
		'src/global/**/*.js',
		'src/*.js'
	]
};

var builds = {
	br: [
		'bower_components/br-validations/releases/br-validations.js',
		'src/br/**/*.js'
	],
	us: [
		'src/us/**/*.js'
	],
};

function customBuild(files, buildName) {
	var buildFilename = 'angular-input-masks';

	if (buildName) {
		buildFilename += '.' + buildName;
	}

	var buildFiles = commonBuild.libs.concat(files).concat(commonBuild.files);

	return function() {
		return gulp.src(buildFiles)
			.pipe(filterNonCodeFiles())
			.pipe(plugins.concat(buildFilename + '.js'))
			.pipe(plugins.header(header, {pkg: pkg}))
			.pipe(plugins.footer(footer))
			.pipe(gulp.dest('./releases/'))
			.pipe(plugins.uglify())
			.pipe(plugins.concat(buildFilename + '.min.js'))
			.pipe(gulp.dest('./releases/'));
	};
}

var buildTasks = [];
var fullBuildFiles = [];
Object.keys(builds).forEach(function(buildName) {
	var taskName = 'build:' + buildName;
	var buildFiles = builds[buildName];
	gulp.task(taskName, customBuild(buildFiles, buildName));
	buildTasks.push(taskName);
	fullBuildFiles = fullBuildFiles.concat(buildFiles);
});

gulp.task('build', buildTasks, customBuild(fullBuildFiles));

gulp.task('jshint', function() {
	return gulp.src(path.src.jshint)
	.pipe(plugins.jshint('.jshintrc'))
	.pipe(plugins.jshint.reporter(jshintReporter))
	.pipe(plugins.jshint.reporter('fail'));
});

gulp.task('default', ['jshint', 'build'], function() {
	gulp.watch(path.src.files, ['jshint', 'build']);
});

gulp.task('serve', ['build'], function() {
	var express = require('express');
	var server = express();

	server.use(express.static('./'));
	server.listen(8000, function() {
		console.log('Server running in port 8000');
	});
});

gulp.task('test:unit', ['jshint'], function(done) {
	var karmaConfig = {
		singleRun: true,
		configFile: __dirname + '/config/karma.conf.js'
	};

	karma.start(karmaConfig, done);
});

gulp.task('test-watch', function(done) {
	var karmaConfig = {
		singleRun: false,
		autoWatch: true,
		configFile: __dirname + '/config/karma.conf.js'
	};

	karma.start(karmaConfig, done);
});

gulp.task('webdriver_update', require('gulp-protractor').webdriver_update);

gulp.task('test:e2e', ['jshint', 'webdriver_update', 'serve', 'test:unit'], function() {
	var protractor = require('gulp-protractor').protractor;

	gulp.src(path.src.e2e)
	.pipe(protractor({
		configFile: 'config/protractor.conf.js'
	}))
	.pipe(plugins.exit());
});

gulp.task('test', ['jshint', 'test:unit', 'test:e2e']);

function filterNonCodeFiles() {
	return plugins.filter(function(file) {
		return !/\.json$|\.spec\.js$|\.test\.js$/.test(file.path);
	});
}
<|endoftext|>


<commit_before>new Test.Unit.Runner({
  setup: function() {
    $('content').update(
      "Lorem ipsum dolor sit amet, " +
      "consectetuer adipiscing elit."
    );

    $('wrapper').cleanWhitespace();

    this.range = document.createRange();
    this.range.selectNode($('content'));
  },

  testSetStart: function() {
    var runner = this;

    this.range.setStart($('content'), 2);
    this.range.setEnd($('content'), 2);

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(2, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "endContainer");
    runner.assertEqual(2, this.range.endOffset, "endOffset");
    runner.assertEqual(true, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");

    this.range.setStart($('lorem'), 0);
    this.range.setEnd($('lorem'), 1);

    runner.assertEqual($('lorem'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('lorem'), this.range.endContainer, "endContainer");
    runner.assertEqual(1, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('lorem'), this.range.commonAncestorContainer, "commonAncestorContainer");
  },

  testSetEnd: function() {
    var runner = this;

    this.range.setStart($('content'), 1);
    this.range.setEnd($('content'), 2);

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(1, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "startContainer");
    runner.assertEqual(2, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");

    this.range.setStart($('consectetuer'), 0);
    this.range.setEnd($('consectetuer'), 1);

    runner.assertEqual($('consectetuer'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('consectetuer'), this.range.endContainer, "startContainer");
    runner.assertEqual(1, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('consectetuer'), this.range.commonAncestorContainer, "commonAncestorContainer");
  },

  testSetStartBefore: function() {
    var runner = this;

    this.range.setStartBefore($('lorem'));
    this.range.setEnd($('content'), 2);

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "endContainer");
    runner.assertEqual(2, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");

    this.range.setStartBefore($('content'));
    this.range.setEnd($('content'), 2);

    runner.assertEqual($('wrapper'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "endContainer");
    runner.assertEqual(2, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('wrapper'), this.range.commonAncestorContainer, "commonAncestorContainer");
  },

  testSetStartAfter: function() {
    var runner = this;

    this.range.setStartAfter($('lorem'));
    this.range.setEnd($('content'), 2);

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(1, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "startContainer");
    runner.assertEqual(2, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");

    this.range.setStartAfter($('content'));
    this.range.setEnd($('wrapper'), 1);

    runner.assertEqual($('wrapper'), this.range.startContainer, "startContainer");
    runner.assertEqual(1, this.range.startOffset, "startOffset");
    runner.assertEqual($('wrapper'), this.range.endContainer, "startContainer");
    runner.assertEqual(1, this.range.endOffset, "endOffset");
    runner.assertEqual(true, this.range.collapsed, "collapsed");
    runner.assertEqual($('wrapper'), this.range.commonAncestorContainer, "commonAncestorContainer");
  },

  testSetEndBefore: function() {
    var runner = this;

    this.range.setStart($('content'), 0);
    this.range.setEndBefore($('lorem'));

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "startContainer");
    runner.assertEqual(0, this.range.endOffset, "endOffset");
    runner.assertEqual(true, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");

    this.range.setStart($('wrapper'), 0);
    this.range.setEndBefore($('content'));

    runner.assertEqual($('wrapper'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('wrapper'), this.range.endContainer, "startContainer");
    runner.assertEqual(0, this.range.endOffset, "endOffset");
    runner.assertEqual(true, this.range.collapsed, "collapsed");
    runner.assertEqual($('wrapper'), this.range.commonAncestorContainer, "commonAncestorContainer");
  },

  testSetEndAfter: function() {
    var runner = this;

    this.range.setStart($('content'), 0);
    this.range.setEndAfter($('lorem'));

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "startContainer");
    runner.assertEqual(1, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");

    this.range.setStart($('content'), 0);
    this.range.setEndAfter($('content'));

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('wrapper'), this.range.endContainer, "startContainer");
    runner.assertEqual(1, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('wrapper'), this.range.commonAncestorContainer, "commonAncestorContainer");
  },

  testCollapse: function() {
    var runner = this;

    this.range.setStart($('content'), 1);
    this.range.setEnd($('content'), 2);
    this.range.collapse(true);

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(1, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "startContainer");
    runner.assertEqual(1, this.range.endOffset, "endOffset");
    runner.assertEqual(true, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");

    this.range.setStart($('content'), 1);
    this.range.setEnd($('content'), 2);
    this.range.collapse(false);

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(2, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "startContainer");
    runner.assertEqual(2, this.range.endOffset, "endOffset");
    runner.assertEqual(true, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");
  },

  testSelectNode: function() {
    var runner = this;

    this.range.selectNode($('content'));

    runner.assertEqual($('wrapper'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('wrapper'), this.range.endContainer, "startContainer");
    runner.assertEqual(1, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('wrapper'), this.range.commonAncestorContainer, "commonAncestorContainer");

    this.range.selectNode($('lorem'));

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "startContainer");
    runner.assertEqual(1, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");
  },

  testSelectNodeContents: function() {
    var runner = this;

    this.range.selectNodeContents($('content'));

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "startContainer");
    runner.assertEqual(4, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");

    this.range.selectNodeContents($('lorem'));

    runner.assertEqual($('lorem'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('lorem'), this.range.endContainer, "startContainer");
    runner.assertEqual(1, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('lorem'), this.range.commonAncestorContainer, "commonAncestorContainer");
  },

  testDeleteContents: function() {
    var runner = this;

    this.range.selectNodeContents($('lorem'));
    this.range.deleteContents();

    runner.assertEqual("", $('lorem').innerHTML, "innerHTML");
  },

  testExtractContents: function() {
    var runner = this;

    this.range.selectNodeContents($('lorem'));
    var contents = this.range.extractContents();

    runner.assertEqual("", $('lorem').innerHTML, "innerHTML");

    // IE document does not have any useful methods. Everyone else can just
    // read textContent, IE needs to append the fragment to another element
    // and read its innerHTML
    if (contents.textContent) {
      runner.assertEqual("Lorem ipsum", contents.textContent, "textContent");
    } else {
      var e = new Element('div');
      e.appendChild(contents);
      runner.assertEqual("Lorem ipsum", e.innerHTML, "textContent");
    }
  },

  testCloneContents: function() {
    var runner = this;

    this.range.selectNodeContents($('lorem'));
    var contents = this.range.cloneContents();

    runner.assertEqual("Lorem ipsum", $('lorem').innerHTML, "innerHTML");

    // IE document does not have any useful methods. Everyone else can just
    // read textContent, IE needs to append the fragment to another element
    // and read its innerHTML
    if (contents.textContent) {
      runner.assertEqual("Lorem ipsum", contents.textContent, "textContent");
    } else {
      var e = new Element('div');
      e.appendChild(contents);
      runner.assertEqual("Lorem ipsum", e.innerHTML, "textContent");
    }
  },

  testInsertNode: function() {
    var runner = this;

    var node = new Element('span', {id: 'inserted'}).update("inserted!");

    this.range.selectNode($('lorem'));
    this.range.insertNode(node);

    runner.assertEqual("inserted!", $('inserted').innerHTML, "innerHTML");

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "startContainer");
    // runner.assertEqual(2, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");
  },

  testSurrondContents: function() {
    var runner = this;

    var node;

    node = new Element('span', {id: 'wrapper'});

    this.range.selectNodeContents($('lorem'));
    this.range.surroundContents(node);

    expected = new Element('div');
    expected.appendChild(new Element('span', {id: 'wrapper'}).update("Lorem ipsum"));

    runner.assertEqual(expected.innerHTML, $('lorem').innerHTML, "innerHTML");
  },

  testEqualRange: function() {
    var runner = this;

    if (!this.range.equalRange) {
      runner.flunk("equalRange is not implemented");
      return false;
    }

    var r1 = document.createRange();
    r1.selectNodeContents($('lorem'));

    var r2 = document.createRange();
    r2.selectNodeContents($('lorem'));

    var r3 = document.createRange();
    r3.selectNodeContents($('consectetuer'));

    runner.assert(r1.equalRange(r1), "r1.equalRange(r1)");
    runner.assert(r2.equalRange(r2), "r2.equalRange(r2)");
    runner.assert(r3.equalRange(r3), "r3.equalRange(r3)");

    runner.assert(r1.equalRange(r2), "r1.equalRange(r2)");
    runner.assert(r2.equalRange(r1), "r2.equalRange(r1)");
    runner.assert(!r1.equalRange(r3), "r1.equalRange(r3)");
    runner.assert(!r3.equalRange(r1), "r3.equalRange(r1)");

    runner.assert(!r1.equalRange(null), "r1.equalRange(null)");
    runner.assert(!r2.equalRange(null), "r2.equalRange(null)");
    runner.assert(!r3.equalRange(null), "r3.equalRange(null)");
  },

  testGetNode: function() {
    var runner = this;

    if (!this.range.getNode) {
      runner.flunk("getNode is not implemented");
      return false;
    }

    this.range.selectNodeContents($('lorem'));
    runner.assertEqual($('lorem'), this.range.getNode(), "getNode");

    this.range.selectNode($('lorem'));
    runner.assertEqual($('lorem'), this.range.getNode(), "getNode");

    this.range.setStart($('lorem'), 0);
    this.range.setEnd($('lorem'), 1);
    runner.assertEqual($('lorem'), this.range.getNode(), "getNode");
  }
});
<commit_msg>pending test for toString<commit_after>new Test.Unit.Runner({
  setup: function() {
    $('content').update(
      "Lorem ipsum dolor sit amet, " +
      "consectetuer adipiscing elit."
    );

    $('wrapper').cleanWhitespace();

    this.range = document.createRange();
    this.range.selectNode($('content'));
  },

  testSetStart: function() {
    var runner = this;

    this.range.setStart($('content'), 2);
    this.range.setEnd($('content'), 2);

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(2, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "endContainer");
    runner.assertEqual(2, this.range.endOffset, "endOffset");
    runner.assertEqual(true, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");
    runner.assertEqual("", this.range.toString(), "toString");

    this.range.setStart($('lorem'), 0);
    this.range.setEnd($('lorem'), 1);

    runner.assertEqual($('lorem'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('lorem'), this.range.endContainer, "endContainer");
    runner.assertEqual(1, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('lorem'), this.range.commonAncestorContainer, "commonAncestorContainer");
    // runner.assertEqual("Lorem ipsum", this.range.toString(), "toString");
  },

  testSetEnd: function() {
    var runner = this;

    this.range.setStart($('content'), 1);
    this.range.setEnd($('content'), 2);

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(1, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "startContainer");
    runner.assertEqual(2, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");
    runner.assertEqual(" dolor sit amet, ", this.range.toString(), "toString");

    this.range.setStart($('consectetuer'), 0);
    this.range.setEnd($('consectetuer'), 1);

    runner.assertEqual($('consectetuer'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('consectetuer'), this.range.endContainer, "startContainer");
    runner.assertEqual(1, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('consectetuer'), this.range.commonAncestorContainer, "commonAncestorContainer");
    // runner.assertEqual("consectetuer", this.range.toString(), "toString");
  },

  testSetStartBefore: function() {
    var runner = this;

    this.range.setStartBefore($('lorem'));
    this.range.setEnd($('content'), 2);

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "endContainer");
    runner.assertEqual(2, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");
    runner.assertEqual("Lorem ipsum dolor sit amet, ", this.range.toString(), "toString");

    this.range.setStartBefore($('content'));
    this.range.setEnd($('content'), 2);

    runner.assertEqual($('wrapper'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "endContainer");
    runner.assertEqual(2, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('wrapper'), this.range.commonAncestorContainer, "commonAncestorContainer");
    runner.assertEqual("Lorem ipsum dolor sit amet, ", this.range.toString(), "toString");
  },

  testSetStartAfter: function() {
    var runner = this;

    this.range.setStartAfter($('lorem'));
    this.range.setEnd($('content'), 2);

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(1, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "startContainer");
    runner.assertEqual(2, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");
    runner.assertEqual(" dolor sit amet, ", this.range.toString(), "toString");

    this.range.setStartAfter($('content'));
    this.range.setEnd($('wrapper'), 1);

    runner.assertEqual($('wrapper'), this.range.startContainer, "startContainer");
    runner.assertEqual(1, this.range.startOffset, "startOffset");
    runner.assertEqual($('wrapper'), this.range.endContainer, "startContainer");
    runner.assertEqual(1, this.range.endOffset, "endOffset");
    runner.assertEqual(true, this.range.collapsed, "collapsed");
    runner.assertEqual($('wrapper'), this.range.commonAncestorContainer, "commonAncestorContainer");
    // runner.assertEqual("", this.range.toString(), "toString");
  },

  testSetEndBefore: function() {
    var runner = this;

    this.range.setStart($('content'), 0);
    this.range.setEndBefore($('lorem'));

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "startContainer");
    runner.assertEqual(0, this.range.endOffset, "endOffset");
    runner.assertEqual(true, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");
    runner.assertEqual("", this.range.toString(), "toString");

    this.range.setStart($('wrapper'), 0);
    this.range.setEndBefore($('content'));

    runner.assertEqual($('wrapper'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('wrapper'), this.range.endContainer, "startContainer");
    runner.assertEqual(0, this.range.endOffset, "endOffset");
    runner.assertEqual(true, this.range.collapsed, "collapsed");
    runner.assertEqual($('wrapper'), this.range.commonAncestorContainer, "commonAncestorContainer");
    runner.assertEqual("", this.range.toString(), "toString");
  },

  testSetEndAfter: function() {
    var runner = this;

    this.range.setStart($('content'), 0);
    this.range.setEndAfter($('lorem'));

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "startContainer");
    runner.assertEqual(1, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");
    runner.assertEqual("Lorem ipsum", this.range.toString(), "toString");

    this.range.setStart($('content'), 0);
    this.range.setEndAfter($('content'));

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('wrapper'), this.range.endContainer, "startContainer");
    runner.assertEqual(1, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('wrapper'), this.range.commonAncestorContainer, "commonAncestorContainer");
    // runner.assertEqual("Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", this.range.toString(), "toString");
  },

  testCollapse: function() {
    var runner = this;

    this.range.setStart($('content'), 1);
    this.range.setEnd($('content'), 2);
    this.range.collapse(true);

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(1, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "startContainer");
    runner.assertEqual(1, this.range.endOffset, "endOffset");
    runner.assertEqual(true, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");
    runner.assertEqual("", this.range.toString(), "toString");

    this.range.setStart($('content'), 1);
    this.range.setEnd($('content'), 2);
    this.range.collapse(false);

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(2, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "startContainer");
    runner.assertEqual(2, this.range.endOffset, "endOffset");
    runner.assertEqual(true, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");
    runner.assertEqual("", this.range.toString(), "toString");
  },

  testSelectNode: function() {
    var runner = this;

    this.range.selectNode($('content'));

    runner.assertEqual($('wrapper'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('wrapper'), this.range.endContainer, "startContainer");
    runner.assertEqual(1, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('wrapper'), this.range.commonAncestorContainer, "commonAncestorContainer");
    // runner.assertEqual("Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", this.range.toString(), "toString");

    this.range.selectNode($('lorem'));

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "startContainer");
    runner.assertEqual(1, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");
    runner.assertEqual("Lorem ipsum", this.range.toString(), "toString");
  },

  testSelectNodeContents: function() {
    var runner = this;

    this.range.selectNodeContents($('content'));

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "startContainer");
    runner.assertEqual(4, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");
    // runner.assertEqual("Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", this.range.toString(), "toString");

    this.range.selectNodeContents($('lorem'));

    runner.assertEqual($('lorem'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('lorem'), this.range.endContainer, "startContainer");
    runner.assertEqual(1, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('lorem'), this.range.commonAncestorContainer, "commonAncestorContainer");
    // runner.assertEqual("Lorem ipsum", this.range.toString(), "toString");
  },

  testDeleteContents: function() {
    var runner = this;

    this.range.selectNodeContents($('lorem'));
    this.range.deleteContents();

    runner.assertEqual("", $('lorem').innerHTML, "innerHTML");
  },

  testExtractContents: function() {
    var runner = this;

    this.range.selectNodeContents($('lorem'));
    var contents = this.range.extractContents();

    runner.assertEqual("", $('lorem').innerHTML, "innerHTML");

    // IE document does not have any useful methods. Everyone else can just
    // read textContent, IE needs to append the fragment to another element
    // and read its innerHTML
    if (contents.textContent) {
      runner.assertEqual("Lorem ipsum", contents.textContent, "textContent");
    } else {
      var e = new Element('div');
      e.appendChild(contents);
      runner.assertEqual("Lorem ipsum", e.innerHTML, "textContent");
    }
  },

  testCloneContents: function() {
    var runner = this;

    this.range.selectNodeContents($('lorem'));
    var contents = this.range.cloneContents();

    runner.assertEqual("Lorem ipsum", $('lorem').innerHTML, "innerHTML");

    // IE document does not have any useful methods. Everyone else can just
    // read textContent, IE needs to append the fragment to another element
    // and read its innerHTML
    if (contents.textContent) {
      runner.assertEqual("Lorem ipsum", contents.textContent, "textContent");
    } else {
      var e = new Element('div');
      e.appendChild(contents);
      runner.assertEqual("Lorem ipsum", e.innerHTML, "textContent");
    }
  },

  testInsertNode: function() {
    var runner = this;

    var node = new Element('span', {id: 'inserted'}).update("inserted!");

    this.range.selectNode($('lorem'));
    this.range.insertNode(node);

    runner.assertEqual("inserted!", $('inserted').innerHTML, "innerHTML");

    runner.assertEqual($('content'), this.range.startContainer, "startContainer");
    runner.assertEqual(0, this.range.startOffset, "startOffset");
    runner.assertEqual($('content'), this.range.endContainer, "startContainer");
    // runner.assertEqual(2, this.range.endOffset, "endOffset");
    runner.assertEqual(false, this.range.collapsed, "collapsed");
    runner.assertEqual($('content'), this.range.commonAncestorContainer, "commonAncestorContainer");
  },

  testSurrondContents: function() {
    var runner = this;

    var node;

    node = new Element('span', {id: 'wrapper'});

    this.range.selectNodeContents($('lorem'));
    this.range.surroundContents(node);

    expected = new Element('div');
    expected.appendChild(new Element('span', {id: 'wrapper'}).update("Lorem ipsum"));

    runner.assertEqual(expected.innerHTML, $('lorem').innerHTML, "innerHTML");
  },

  testEqualRange: function() {
    var runner = this;

    if (!this.range.equalRange) {
      runner.flunk("equalRange is not implemented");
      return false;
    }

    var r1 = document.createRange();
    r1.selectNodeContents($('lorem'));

    var r2 = document.createRange();
    r2.selectNodeContents($('lorem'));

    var r3 = document.createRange();
    r3.selectNodeContents($('consectetuer'));

    runner.assert(r1.equalRange(r1), "r1.equalRange(r1)");
    runner.assert(r2.equalRange(r2), "r2.equalRange(r2)");
    runner.assert(r3.equalRange(r3), "r3.equalRange(r3)");

    runner.assert(r1.equalRange(r2), "r1.equalRange(r2)");
    runner.assert(r2.equalRange(r1), "r2.equalRange(r1)");
    runner.assert(!r1.equalRange(r3), "r1.equalRange(r3)");
    runner.assert(!r3.equalRange(r1), "r3.equalRange(r1)");

    runner.assert(!r1.equalRange(null), "r1.equalRange(null)");
    runner.assert(!r2.equalRange(null), "r2.equalRange(null)");
    runner.assert(!r3.equalRange(null), "r3.equalRange(null)");
  },

  testGetNode: function() {
    var runner = this;

    if (!this.range.getNode) {
      runner.flunk("getNode is not implemented");
      return false;
    }

    this.range.selectNodeContents($('lorem'));
    runner.assertEqual($('lorem'), this.range.getNode(), "getNode");

    this.range.selectNode($('lorem'));
    runner.assertEqual($('lorem'), this.range.getNode(), "getNode");

    this.range.setStart($('lorem'), 0);
    this.range.setEnd($('lorem'), 1);
    runner.assertEqual($('lorem'), this.range.getNode(), "getNode");
  }
});
<|endoftext|>