<commit_before>/**
 * Nanocloud turns any traditional software into a cloud solution, without
 * changing or redeveloping existing source code.
 *
 * Copyright (C) 2016 Nanocloud Software
 *
 * This file is part of Nanocloud.
 *
 * Nanocloud is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * Nanocloud is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

const drive = '/data/image.qcow2';

var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var multer = require('multer'); // v1.0.5
var upload = multer(); // for parsing multipart/form-data
var uuid = require('uuid');
var exec = require('child_process').exec;

function getPort() {
  getPort.plaza =  ++getPort.plaza || 28000;
  getPort.rdp =  ++getPort.rdp || 29000;
  getPort.vnc =  ++getPort.vnc || 1;

  return ({
    plaza: getPort.plaza,
    rdp: getPort.rdp,
    vnc: getPort.vnc
  });
}

app.use(function(req, res, next) {
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
  next();
});
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded

app.post('/machines', upload.array(), function (req, res) {
  var machineDescription = req.body;
  var id = uuid.v4();
  var name = machineDescription.name + '-qemu-' + id;
  var port = getPort();
  var cmd = `qemu-system-x86_64 \
    -nodefaults \
    -name "${name}" \
    -m ${machineDescription.memory} \
    -smp ${machineDescription.cpu} \
    -machine accel=kvm \
    -drive file=${drive},format=qcow2 \
    -vnc :${port.vnc} \
    -usb -device usb-tablet \
    -net nic,vlan=0,model=virtio \
    -net user,vlan=0,hostfwd=tcp::${port.plaza}-:9090,hostfwd=tcp::${port.rdp}-:3389 \
    -vga qxl \
  `;

  exec(cmd, () => {});

  return res.json({
    id: id,
    name: name,
    plazaPort: port.plaza,
    rdpPort: port.rdp,
    vncPort: port.vnc,
    status: 'booting'
  });

});

app.delete('/machines/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}', function (req, res) {

  var machineId = req.path.substr(10);

  exec('PID=$(ps aux | grep "' + machineId + ' " | grep qemu | awk \'{ print $2 }\' | tr "\\n" " ") ; kill ${PID}',
    () => {});

  return res.json({
    id: machineId,
    status: 'stopping'
  });

});

app.get('/', function (req, res) {
  return res.send('Qemu manager');
});

app.listen(3000, function () {
  // Qemu Manager listen on port 3000
});
<commit_msg>Add socket to manage vm<commit_after>/**
 * Nanocloud turns any traditional software into a cloud solution, without
 * changing or redeveloping existing source code.
 *
 * Copyright (C) 2016 Nanocloud Software
 *
 * This file is part of Nanocloud.
 *
 * Nanocloud is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * Nanocloud is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

const net = require('net');
const drive = '/data/image.qcow2';

var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var multer = require('multer'); // v1.0.5
var upload = multer(); // for parsing multipart/form-data
var uuid = require('uuid');
var exec = require('child_process').exec;

function getPort() {
  getPort.plaza =  ++getPort.plaza || 28000;
  getPort.rdp =  ++getPort.rdp || 29000;
  getPort.vnc =  ++getPort.vnc || 1;

  return ({
    plaza: getPort.plaza,
    rdp: getPort.rdp,
    vnc: getPort.vnc
  });
}

app.use(function(req, res, next) {
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
  next();
});
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded

app.post('/machines', upload.array(), function (req, res) {
  var machineDescription = req.body;
  var id = uuid.v4();
  var name = machineDescription.name + '-qemu-' + id;
  var port = getPort();
  var cmd = `qemu-system-x86_64 \
    -nodefaults \
    -name "${name}" \
    -m ${machineDescription.memory} \
    -smp ${machineDescription.cpu} \
    -machine accel=kvm \
    -drive file=${drive},format=qcow2 \
    -vnc :${port.vnc} \
    -usb -device usb-tablet \
    -net nic,vlan=0,model=virtio \
    -net user,vlan=0,hostfwd=tcp::${port.plaza}-:9090,hostfwd=tcp::${port.rdp}-:3389 \
    -monitor unix:/data/${id}.socket,server,nowait \
    -vga qxl \
  `;

  exec(cmd, () => {});

  return res.json({
    id: id,
    name: name,
    plazaPort: port.plaza,
    rdpPort: port.rdp,
    vncPort: port.vnc,
    status: 'booting'
  });

});

app.delete('/machines/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}', function (req, res) {

  var machineId = req.path.substr(10);
  let socket = net.connect({path: '/data/' + machineId + '.socket'}, () => {
    socket.write('system_powerdown\n', () => {
      return res.json({
        id: machineId,
        status: 'stopping'
      });
    });
  });
});

app.get('/', function (req, res) {
  return res.send('Qemu manager');
});

app.listen(3000, function () {
  // Qemu Manager listen on port 3000
});
<|endoftext|>


<commit_before>'use strict';

/**
 * Simple wrapper for 'Error' to provide a HTTP status code.
 */
module.exports = function(status, message) {
	if(message instanceof Error) {
		message.status = status;
		return message;
	}
	var error        = new Error(message);
	    error.status = status;
	return error;
}
<commit_msg>Add documentation for 'utils/error'.<commit_after>'use strict';

/**
 * Simple utility that enhances the given error with a 'status' field.
 *
 * @param  {Number}          status   HTTP status code.
 * @param  {(String|Error)}  message  Message describing the error, can also be
 *                                    an instance of Error.
 *
 * @returns  {Error}  Error object enhanced with a 'status'.
 */
module.exports = function(status, message) {
	if(message instanceof Error) {
		message.status = status;
		return message;
	}
	var error        = new Error(message);
	    error.status = status;
	return error;
}
<|endoftext|>


<commit_before>// @ts-check
'use strict';

const XRegExp = require('xregexp');

const strip = ({ id, username }) =>
	id ? { id } : { username: username.toLowerCase() };

const toUserObject = s =>
	s.user || (/^\d+$/.test(s) ? { id: +s } : { username: s.replace('@', '') });

const isTextMention = m => m.type === 'text_mention';

const spliceOut = (s, { offset, length }) =>
	s.slice(0, offset) + s.slice(offset + length);

const botReply = ({ from, entities = [] }) => {
	const textMentions = entities.filter(isTextMention);

	return from.is_bot && textMentions.length === 2 && [ textMentions[1].user ];
};

const flagsRegex = /\s+(?:--?|—)(\w+)(?:=(\S*))?/g;

/** @returns {Generator<[string, string | undefined]>} */
function *extractFlags(flagS) {
	for (const [ , name, value ] of flagS.matchAll(flagsRegex)) {
		yield [ name.toLowerCase(), value ];
	}
}

const regex = XRegExp.tag('snx')`^
	\/\w+(@\w+)?
	(?<flagS> ${flagsRegex}*)
	(?<ids> (\s+@\w+|\s+\d+)*)
	(?:\s+(?<reason>.*))?
$`;

const parse = message => {
	const textMentions = message.entities.filter(isTextMention);
	const noTextMentions = textMentions.reduceRight(spliceOut, message.text);

	const { flagS, ids, reason = '' } = XRegExp.exec(noTextMentions, regex);
	const flags = new Map(extractFlags(flagS));
	const users = textMentions.concat(ids.match(/@\w+|\d+/g) || []);
	const { reply_to_message } = message;
	const targets = users.length
		? users.map(toUserObject)
		: reply_to_message
			? botReply(reply_to_message) || [ reply_to_message.from ]
			: [];

	return { flags, reason, targets };
};

module.exports = {
	parse,
	strip,
};
<commit_msg>Allow to separate users and reason using --<commit_after>// @ts-check
'use strict';

const XRegExp = require('xregexp');

const strip = ({ id, username }) =>
	id ? { id } : { username: username.toLowerCase() };

const toUserObject = s =>
	s.user || (/^\d+$/.test(s) ? { id: +s } : { username: s.replace('@', '') });

const isTextMention = m => m.type === 'text_mention';

const spliceOut = (s, { offset, length }) =>
	s.slice(0, offset) + s.slice(offset + length);

const botReply = ({ from, entities = [] }) => {
	const textMentions = entities.filter(isTextMention);

	return from.is_bot && textMentions.length === 2 && [ textMentions[1].user ];
};

const flagsRegex = /\s+(?:--?|—)(\w+)(?:=(\S*))?/g;

/** @returns {Generator<[string, string | undefined]>} */
function *extractFlags(flagS) {
	for (const [ , name, value ] of flagS.matchAll(flagsRegex)) {
		yield [ name.toLowerCase(), value ];
	}
}

const regex = XRegExp.tag('snx')`^
	\/\w+(@\w+)?
	(?<flagS> ${flagsRegex}*)
	(?<ids> (\s+@\w+|\s+\d+)*)
	(?:\s+--|\s+—)?
	(?:\s+(?<reason>.*))?
$`;

const parse = message => {
	const textMentions = message.entities.filter(isTextMention);
	const noTextMentions = textMentions.reduceRight(spliceOut, message.text);

	const { flagS, ids, reason = '' } = XRegExp.exec(noTextMentions, regex);
	const flags = new Map(extractFlags(flagS));
	const users = textMentions.concat(ids.match(/@\w+|\d+/g) || []);
	const { reply_to_message } = message;
	const targets = users.length
		? users.map(toUserObject)
		: reply_to_message
			? botReply(reply_to_message) || [ reply_to_message.from ]
			: [];

	return { flags, reason, targets };
};

module.exports = {
	parse,
	strip,
};
<|endoftext|>


<commit_before>function defineKnownQuantity(quantity, unitShortName, description) {
  var rootQuanitity = quantity;
  var rootUnit = UNITS[unitShortName];
  do {
    rootQuanitity *= rootUnit.multiplier || 1;
    rootUnit = UNITS[rootUnit.unit];
  } while (!isRootUnit(rootUnit));

  if (!KNOWN_QUANTITIES[rootUnit.shortName]) {
    KNOWN_QUANTITIES[rootUnit.shortName] = [];
  }
  KNOWN_QUANTITIES[rootUnit.shortName].push({
    quantity: rootQuanitity,
    description: description
  });
}

var KNOWN_QUANTITIES = {};

/********************  Length  ********************/

defineKnownQuantity(25, 'pm', '| times the radius of a hydrogen atom');
defineKnownQuantity(1, 'nm', '| times the width of a carbon nanotube');
defineKnownQuantity(90, 'nm', '| times the width of the HIV virus');
defineKnownQuantity(7, 'um', '| times the diameter of a red blood cell');
defineKnownQuantity(100, 'um', '| times the width of a human hair');
defineKnownQuantity(0.004, 'in', '$| in stacked $1 bills');
defineKnownQuantity(0.3, 'mm', '| grains of sand in a line');
defineKnownQuantity(0.4, 'mm', '| times the thickness of a fingernail');
defineKnownQuantity(4.267, 'cm', '| golf balls stacked on top of each other');
defineKnownQuantity(7, 'cm', '| chap sticks long');
defineKnownQuantity(13.5, 'cm', '| Sharpie markers');
defineKnownQuantity(1.7, 'm', '| times the average height of a human');
defineKnownQuantity(45, 'ft', '| school buses long');
defineKnownQuantity(30, 'm', '| blue whales lined up end-to-end');
defineKnownQuantity(100, 'yd', '| (American) football fields long');
defineKnownQuantity(70.6, 'm', '| Boeing 747s long');
defineKnownQuantity(93.47, 'm', '| Statues of Liberty stacked on top of each other');
defineKnownQuantity(137, 'm', '| times the height of the Great Pyramid of Giza');
defineKnownQuantity(301, 'm', '| Eiffel Towers high');
defineKnownQuantity(838, 'm', '| times the height of the Burj Khalifa, the tallest building in the world');
defineKnownQuantity(4896, 'mi', '| trips from New York to LA and back');
defineKnownQuantity(17406, 'mi', '| trips from LA to Mumbai and back');
defineKnownQuantity(3480, 'km', '| times the width of the Moon');
defineKnownQuantity(6400, 'km', '| walks down the entire Great Wall of China');
defineKnownQuantity(40075, 'km', '| times the Earth\'s circumference (at the equator)');
defineKnownQuantity(299792, 'km', '| light seconds');
defineKnownQuantity(1390000, 'km', '| times the width of the Sun');
defineKnownQuantity(1, 'au', '| times the distance from the Earth to the Sun');
defineKnownQuantity(29.657, 'au', '| times the shortest distance from the Sun to Pluto');
defineKnownQuantity(4.243, 'ly', '| times the distance from our sun to the next nearest star, Proxima Centauri');
defineKnownQuantity(1000, 'ly', '| times the average thickness of the Milky Way galaxy');
defineKnownQuantity(100000, 'ly', '| times the diameter of the Milky Way galaxy');
defineKnownQuantity(2540000, 'ly', '| trips to the nearest spiral galaxy, the Andromeda Galaxy.');
defineKnownQuantity(92000000000, 'ly', '| times the diameter of the observable universe');

/********************  Time  ********************/

defineKnownQuantity(12, 'as', '| times the shortest measured period of time');
defineKnownQuantity(1, 'ns', '| machine cycles by a 1 GHz microprocessor');
defineKnownQuantity(1.0167, 'ns', '| times the amount of time it takes light to travel a foot');
defineKnownQuantity(1, 'ms', '| sequential human nueral firings');
defineKnownQuantity(350, 'ms', '| blinks of an eye');
defineKnownQuantity(500000, 'y', '| times the age of modern humans');
defineKnownQuantity(65000000, 'y', '| times the time dinosaurs have been extinct');
defineKnownQuantity(4000000000, 'y', '| times the age of life on Earth');
defineKnownQuantity(143, 'Ps', '| times the age of Earth');
defineKnownQuantity(144, 'Ps', '| times the age of the Solar System');
defineKnownQuantity(430, 'Ps', '| times the age of the Universe');

/********************  Mass / Weight  ********************/

defineKnownQuantity(9.11e-31, 'kg', '| electrons');
defineKnownQuantity(1.673e-27, 'kg', '| protons');
defineKnownQuantity(1.674e-27, 'kg', '| hydrogen atoms');
defineKnownQuantity(3e-26, 'kg', '| water molecules');
defineKnownQuantity(8e-26, 'kg', '| titanium atoms');
defineKnownQuantity(3.2e-25, 'kg', '| caffeine molecules');
defineKnownQuantity(3.5e-25, 'kg', '| lead-208 atoms');
defineKnownQuantity(1e-18, 'kg', '| HIV-1 viruses');
defineKnownQuantity(6e-15, 'kg', '| human DNA molecules');
defineKnownQuantity(2.2e-14, 'kg', '| human sperm cells');
defineKnownQuantity(1e-12, 'kg', '| average human cells');
defineKnownQuantity(1.67e-9, 'kg', '| grains of sand');
defineKnownQuantity(7e-8, 'kg', '| human eyebrow hairs');
defineKnownQuantity(2.5e-7, 'kg', '| fruit flies');
defineKnownQuantity(2e-5, 'kg', '| houseflies');
defineKnownQuantity(0.52, 'g', '| raisins');
defineKnownQuantity(1, 'g', '| US dollar bills');
defineKnownQuantity(1.4, 'g', '| standard paperclips');
defineKnownQuantity(30, 'g', '| mice (the furry kind)');
defineKnownQuantity(6.4, 'oz', '| apples');
defineKnownQuantity(430, 'g', '| soccer balls (or "footballs" if live outside the U.S.)');
defineKnownQuantity(2, 'kg', '| Chihuahuas');
defineKnownQuantity(3.25, 'kg', '| newborn babies');
defineKnownQuantity(4.5, 'kg', '| cats');
defineKnownQuantity(155, 'kg', '| lions');
defineKnownQuantity(345, 'kg', '| grand pianos');
defineKnownQuantity(650, 'kg', '| cows');
defineKnownQuantity(2754, 'lb', '| 2014 Honda Civic LXs');
defineKnownQuantity(1750, 'kg', '| rhinos');
defineKnownQuantity(1.8e5, 'kg', '| blue whales');
defineKnownQuantity(735000, 'lb', '| fully-loaded Boeing 747s');
defineKnownQuantity(4.2e5, 'kg', '| International Space Stations');
defineKnownQuantity(7.8e6, 'kg', '| Virginia-class nuclear submarines');
defineKnownQuantity(5.2e7, 'kg', '| RMS Titanics');
defineKnownQuantity(6e9, 'kg', '| Great Pyramids of Giza');
defineKnownQuantity(4e11, 'kg', '| times the total biomass of the human population');

/********************  Speed  ********************/

defineKnownQuantity(5, 'km/h', '| times the average human walking speed');

/********************  Area  ********************/

defineKnownQuantity(1.767, 'mm2', '| heads of a pin');
defineKnownQuantity(252, 'mm2', '| dimes');
defineKnownQuantity(2500, 'mm2', '| monarch butterfly wings');
defineKnownQuantity(1, 'cm2', '| fingernails');
defineKnownQuantity(20, 'cm2', '| matchbooks');
defineKnownQuantity(4620.688, 'mm2', '| credit cards');
defineKnownQuantity(8.75, 'cm2', '| playing cards');
defineKnownQuantity(14.7, 'in2', '| Polaroid pictures');
defineKnownQuantity(4 * 6, 'in2', '| postcards');
defineKnownQuantity(63.617, 'in2', '| dinner plates');
defineKnownQuantity(77 * 53, 'cm2', '| Mona Lisas');
defineKnownQuantity(27 * 40, 'in2', '| movie posters');
defineKnownQuantity(50 * 60, 'in2', '| picnic blankets');
defineKnownQuantity(4350, 'in2', '| 12\' long cafeteria tables');
defineKnownQuantity(8.5 * 11, 'in2', '| US letter sheets of paper');
defineKnownQuantity(57600, 'ft2', '| American football fields');
defineKnownQuantity(7140, 'm2', '| soccer pitches');
defineKnownQuantity(696241, 'km2', '| Texases');
defineKnownQuantity(7692000, 'km2', '| Australias');
defineKnownQuantity(9597000, 'km2', '| Chinas');
defineKnownQuantity(30220000, 'km2', '| Africas');

/********************  Volume  ********************/

defineKnownQuantity(60, 'mm\u00B3', '| large raindrops');
defineKnownQuantity(1, 'cup', '| cups of coffee');
defineKnownQuantity(52.8, 'ft\u00B3', '| 2015 F-150 truck beds');

/********************  Memory  ********************/

defineKnownQuantity(1, 'B', '| ASCII letters');
defineKnownQuantity(4, 'KB', '| Apple II RAMs');
defineKnownQuantity(1440, 'kB', '| 3.5" floppy disks');
defineKnownQuantity(3, 'MB', '| 10 megapixel photos');
defineKnownQuantity(3.5, 'MB', '| mp3s');
defineKnownQuantity(10, 'MB', '| 1985-er consumer hard drives');
defineKnownQuantity(750, 'MB', '| CDs');
defineKnownQuantity(800, 'MB', '| human genomes');
defineKnownQuantity(1 / 7, 'GB', '| minutes of HDTV video');
defineKnownQuantity(4, 'GB', '| DVD movies');
defineKnownQuantity(10, 'GB', '| 2000-era consumer hard drives');
defineKnownQuantity(25, 'GB', '| single-layer Blue-ray Discs');
defineKnownQuantity(5.87, 'TB', '| times the size of Wikipedia in January 2010');
defineKnownQuantity(10, 'TB', '| times the amount of printed data in the Library of Congress');
defineKnownQuantity(45, 'TB', '| times the amount of data the Hubble Space Telescope collected ' +
                              'in its first 20 years of observation');
defineKnownQuantity(100, 'TB', '| times the amount of total Internet traffic in 1993');
defineKnownQuantity(24, 'PB', '| times the amount of data Google processed per day in 2009');
defineKnownQuantity(8, 'EB', '| Utah NSA data centers');
defineKnownQuantity(15, 'EB', '| times the entire data capacity of Google in 2013');
defineKnownQuantity(4, 'ZB', '| times the size of the entire World Wide Web in 2013');

/********************  Currency  ********************/

defineKnownQuantity(0.5, 'USD', '| packs of gum');
defineKnownQuantity(1, 'USD', '| cans of Coca-Cola');
defineKnownQuantity(1.65, 'USD', '| McDonalds cheeseburgers');
defineKnownQuantity(1.814368, 'USD', '| pounds in American pennies');
defineKnownQuantity(4.99, 'USD', '| loaves of bread');
defineKnownQuantity(7.25, 'USD', '| hours of work at a minimum wage job in America');
defineKnownQuantity(15.99, 'USD', '| t-shirts');
defineKnownQuantity(39.99, 'USD', '| pairs of Levi\'s jeans');
defineKnownQuantity(80, 'USD', '| nice dinners for 2 in Los Angeles');
defineKnownQuantity(247, 'USD', '| weeks of food for an American family of 4');
defineKnownQuantity(400, 'USD', '| bargain 50" TVs');
defineKnownQuantity(468, 'USD', '| gallons of loose change');
defineKnownQuantity(616, 'USD', '| times the average yearly income in India');
defineKnownQuantity(1999, 'USD', '| top-of-the-line MacBook Pros');
defineKnownQuantity(3763, 'USD', '| months in an average Manhattan apartment in 2014');
defineKnownQuantity(18290, 'USD', '| sticker-priced 2015 Honda Civics');
defineKnownQuantity(100000, 'USD', '| rural 2-bedroom American homes');
defineKnownQuantity(1200000, 'USD', '| briefcases full of $100 bills');
defineKnownQuantity(1914000, 'USD', '| Bugatti Veyrons');
defineKnownQuantity(274000000, 'USD', '| Paul Cézanne\'s "The Card Players"');
defineKnownQuantity(10500000000, 'USD', '| times Mark Zuckerberg\'s 2013 earnings');
defineKnownQuantity(73500000000, 'USD', '| times Warren Buffett\'s 2014 net worth');
defineKnownQuantity(77608740000000, 'USD', '| times the total global GDP in 2014');

// Sort the quantities.
for (var unitShortName in KNOWN_QUANTITIES) {
  KNOWN_QUANTITIES[unitShortName].sort(function(a, b) {
    return a.quantity - b.quantity;
  });
}<commit_msg>Adds additional time quantities<commit_after>function defineKnownQuantity(quantity, unitShortName, description) {
  var rootQuanitity = quantity;
  var rootUnit = UNITS[unitShortName];
  do {
    rootQuanitity *= rootUnit.multiplier || 1;
    rootUnit = UNITS[rootUnit.unit];
  } while (!isRootUnit(rootUnit));

  if (!KNOWN_QUANTITIES[rootUnit.shortName]) {
    KNOWN_QUANTITIES[rootUnit.shortName] = [];
  }
  KNOWN_QUANTITIES[rootUnit.shortName].push({
    quantity: rootQuanitity,
    description: description
  });
}

var KNOWN_QUANTITIES = {};

/********************  Length  ********************/

defineKnownQuantity(25, 'pm', '| times the radius of a hydrogen atom');
defineKnownQuantity(1, 'nm', '| times the width of a carbon nanotube');
defineKnownQuantity(90, 'nm', '| times the width of the HIV virus');
defineKnownQuantity(7, 'um', '| times the diameter of a red blood cell');
defineKnownQuantity(100, 'um', '| times the width of a human hair');
defineKnownQuantity(0.004, 'in', '$| in stacked $1 bills');
defineKnownQuantity(0.3, 'mm', '| grains of sand in a line');
defineKnownQuantity(0.4, 'mm', '| times the thickness of a fingernail');
defineKnownQuantity(4.267, 'cm', '| golf balls stacked on top of each other');
defineKnownQuantity(7, 'cm', '| chap sticks long');
defineKnownQuantity(13.5, 'cm', '| Sharpie markers');
defineKnownQuantity(1.7, 'm', '| times the average height of a human');
defineKnownQuantity(45, 'ft', '| school buses long');
defineKnownQuantity(30, 'm', '| blue whales lined up end-to-end');
defineKnownQuantity(100, 'yd', '| (American) football fields long');
defineKnownQuantity(70.6, 'm', '| Boeing 747s long');
defineKnownQuantity(93.47, 'm', '| Statues of Liberty stacked on top of each other');
defineKnownQuantity(137, 'm', '| times the height of the Great Pyramid of Giza');
defineKnownQuantity(301, 'm', '| Eiffel Towers high');
defineKnownQuantity(838, 'm', '| times the height of the Burj Khalifa, the tallest building in the world');
defineKnownQuantity(4896, 'mi', '| trips from New York to LA and back');
defineKnownQuantity(17406, 'mi', '| trips from LA to Mumbai and back');
defineKnownQuantity(3480, 'km', '| times the width of the Moon');
defineKnownQuantity(6400, 'km', '| walks down the entire Great Wall of China');
defineKnownQuantity(40075, 'km', '| times the Earth\'s circumference (at the equator)');
defineKnownQuantity(299792, 'km', '| light seconds');
defineKnownQuantity(1390000, 'km', '| times the width of the Sun');
defineKnownQuantity(1, 'au', '| times the distance from the Earth to the Sun');
defineKnownQuantity(29.657, 'au', '| times the shortest distance from the Sun to Pluto');
defineKnownQuantity(4.243, 'ly', '| times the distance from our sun to the next nearest star, Proxima Centauri');
defineKnownQuantity(1000, 'ly', '| times the average thickness of the Milky Way galaxy');
defineKnownQuantity(100000, 'ly', '| times the diameter of the Milky Way galaxy');
defineKnownQuantity(2540000, 'ly', '| trips to the nearest spiral galaxy, the Andromeda Galaxy.');
defineKnownQuantity(92000000000, 'ly', '| times the diameter of the observable universe');

/********************  Time  ********************/

defineKnownQuantity(12, 'as', '| times the shortest measured period of time');
defineKnownQuantity(1, 'ns', '| machine cycles by a 1 GHz microprocessor');
defineKnownQuantity(1.0167, 'ns', '| times the amount of time it takes light to travel a foot');
defineKnownQuantity(1, 'ms', '| sequential human nueral firings');
defineKnownQuantity(350, 'ms', '| blinks of an eye');
defineKnownQuantity(1 / 17, 's', '| resting canary heartbeats');
defineKnownQuantity(60 / 80, 's', '| resting human heartbeats');
defineKnownQuantity(5.25, 's', '| world-record Rubik's cube solutions);
defineKnownQuantity(9.58, 's', '| world-record 100m dashes');
defineKnownQuantity(30, 'min', '| lunch breaks');
defineKnownQuantity(1, 'hr', '| episodes of Game of Thrones');
defineKnownQuantity(35, 'hr', '| iPhone 6 battery lives');
defineKnownQuantity(3, 'mo', '| summer vacations');
defineKnownQuantity(9, 'mo', '| human pregnancies');
defineKnownQuantity(13, 'y', '| childhoods');
defineKnownQuantity(30, 'y', '| generations');
defineKnownQuantity(70, 'y', '| human lifetimes');
defineKnownQuantity(500000, 'y', '| times the age of modern humans');
defineKnownQuantity(65000000, 'y', '| times the time dinosaurs have been extinct');
defineKnownQuantity(4000000000, 'y', '| times the age of life on Earth');
defineKnownQuantity(143, 'Ps', '| times the age of Earth');
defineKnownQuantity(144, 'Ps', '| times the age of the Solar System');
defineKnownQuantity(430, 'Ps', '| times the age of the Universe');

/********************  Mass / Weight  ********************/

defineKnownQuantity(9.11e-31, 'kg', '| electrons');
defineKnownQuantity(1.673e-27, 'kg', '| protons');
defineKnownQuantity(1.674e-27, 'kg', '| hydrogen atoms');
defineKnownQuantity(3e-26, 'kg', '| water molecules');
defineKnownQuantity(8e-26, 'kg', '| titanium atoms');
defineKnownQuantity(3.2e-25, 'kg', '| caffeine molecules');
defineKnownQuantity(3.5e-25, 'kg', '| lead-208 atoms');
defineKnownQuantity(1e-18, 'kg', '| HIV-1 viruses');
defineKnownQuantity(6e-15, 'kg', '| human DNA molecules');
defineKnownQuantity(2.2e-14, 'kg', '| human sperm cells');
defineKnownQuantity(1e-12, 'kg', '| average human cells');
defineKnownQuantity(1.67e-9, 'kg', '| grains of sand');
defineKnownQuantity(7e-8, 'kg', '| human eyebrow hairs');
defineKnownQuantity(2.5e-7, 'kg', '| fruit flies');
defineKnownQuantity(2e-5, 'kg', '| houseflies');
defineKnownQuantity(0.52, 'g', '| raisins');
defineKnownQuantity(1, 'g', '| US dollar bills');
defineKnownQuantity(1.4, 'g', '| standard paperclips');
defineKnownQuantity(30, 'g', '| mice (the furry kind)');
defineKnownQuantity(6.4, 'oz', '| apples');
defineKnownQuantity(430, 'g', '| soccer balls (or "footballs" if live outside the U.S.)');
defineKnownQuantity(2, 'kg', '| Chihuahuas');
defineKnownQuantity(3.25, 'kg', '| newborn babies');
defineKnownQuantity(4.5, 'kg', '| cats');
defineKnownQuantity(155, 'kg', '| lions');
defineKnownQuantity(345, 'kg', '| grand pianos');
defineKnownQuantity(650, 'kg', '| cows');
defineKnownQuantity(2754, 'lb', '| 2014 Honda Civic LXs');
defineKnownQuantity(1750, 'kg', '| rhinos');
defineKnownQuantity(1.8e5, 'kg', '| blue whales');
defineKnownQuantity(735000, 'lb', '| fully-loaded Boeing 747s');
defineKnownQuantity(4.2e5, 'kg', '| International Space Stations');
defineKnownQuantity(7.8e6, 'kg', '| Virginia-class nuclear submarines');
defineKnownQuantity(5.2e7, 'kg', '| RMS Titanics');
defineKnownQuantity(6e9, 'kg', '| Great Pyramids of Giza');
defineKnownQuantity(4e11, 'kg', '| times the total biomass of the human population');

/********************  Speed  ********************/

defineKnownQuantity(5, 'km/h', '| times the average human walking speed');

/********************  Area  ********************/

defineKnownQuantity(1.767, 'mm2', '| heads of a pin');
defineKnownQuantity(252, 'mm2', '| dimes');
defineKnownQuantity(2500, 'mm2', '| monarch butterfly wings');
defineKnownQuantity(1, 'cm2', '| fingernails');
defineKnownQuantity(20, 'cm2', '| matchbooks');
defineKnownQuantity(4620.688, 'mm2', '| credit cards');
defineKnownQuantity(8.75, 'cm2', '| playing cards');
defineKnownQuantity(14.7, 'in2', '| Polaroid pictures');
defineKnownQuantity(4 * 6, 'in2', '| postcards');
defineKnownQuantity(63.617, 'in2', '| dinner plates');
defineKnownQuantity(77 * 53, 'cm2', '| Mona Lisas');
defineKnownQuantity(27 * 40, 'in2', '| movie posters');
defineKnownQuantity(50 * 60, 'in2', '| picnic blankets');
defineKnownQuantity(4350, 'in2', '| 12\' long cafeteria tables');
defineKnownQuantity(8.5 * 11, 'in2', '| US letter sheets of paper');
defineKnownQuantity(57600, 'ft2', '| American football fields');
defineKnownQuantity(7140, 'm2', '| soccer pitches');
defineKnownQuantity(696241, 'km2', '| Texases');
defineKnownQuantity(7692000, 'km2', '| Australias');
defineKnownQuantity(9597000, 'km2', '| Chinas');
defineKnownQuantity(30220000, 'km2', '| Africas');

/********************  Volume  ********************/

defineKnownQuantity(60, 'mm\u00B3', '| large raindrops');
defineKnownQuantity(1, 'cup', '| cups of coffee');
defineKnownQuantity(52.8, 'ft\u00B3', '| 2015 F-150 truck beds');

/********************  Memory  ********************/

defineKnownQuantity(1, 'B', '| ASCII letters');
defineKnownQuantity(4, 'KB', '| Apple II RAMs');
defineKnownQuantity(1440, 'kB', '| 3.5" floppy disks');
defineKnownQuantity(3, 'MB', '| 10 megapixel photos');
defineKnownQuantity(3.5, 'MB', '| mp3s');
defineKnownQuantity(10, 'MB', '| 1985-er consumer hard drives');
defineKnownQuantity(750, 'MB', '| CDs');
defineKnownQuantity(800, 'MB', '| human genomes');
defineKnownQuantity(1 / 7, 'GB', '| minutes of HDTV video');
defineKnownQuantity(4, 'GB', '| DVD movies');
defineKnownQuantity(10, 'GB', '| 2000-era consumer hard drives');
defineKnownQuantity(25, 'GB', '| single-layer Blue-ray Discs');
defineKnownQuantity(5.87, 'TB', '| times the size of Wikipedia in January 2010');
defineKnownQuantity(10, 'TB', '| times the amount of printed data in the Library of Congress');
defineKnownQuantity(45, 'TB', '| times the amount of data the Hubble Space Telescope collected ' +
                              'in its first 20 years of observation');
defineKnownQuantity(100, 'TB', '| times the amount of total Internet traffic in 1993');
defineKnownQuantity(24, 'PB', '| times the amount of data Google processed per day in 2009');
defineKnownQuantity(8, 'EB', '| Utah NSA data centers');
defineKnownQuantity(15, 'EB', '| times the entire data capacity of Google in 2013');
defineKnownQuantity(4, 'ZB', '| times the size of the entire World Wide Web in 2013');

/********************  Currency  ********************/

defineKnownQuantity(0.5, 'USD', '| packs of gum');
defineKnownQuantity(1, 'USD', '| cans of Coca-Cola');
defineKnownQuantity(1.65, 'USD', '| McDonalds cheeseburgers');
defineKnownQuantity(1.814368, 'USD', '| pounds in American pennies');
defineKnownQuantity(4.99, 'USD', '| loaves of bread');
defineKnownQuantity(7.25, 'USD', '| hours of work at a minimum wage job in America');
defineKnownQuantity(15.99, 'USD', '| t-shirts');
defineKnownQuantity(39.99, 'USD', '| pairs of Levi\'s jeans');
defineKnownQuantity(80, 'USD', '| nice dinners for 2 in Los Angeles');
defineKnownQuantity(247, 'USD', '| weeks of food for an American family of 4');
defineKnownQuantity(400, 'USD', '| bargain 50" TVs');
defineKnownQuantity(468, 'USD', '| gallons of loose change');
defineKnownQuantity(616, 'USD', '| times the average yearly income in India');
defineKnownQuantity(1999, 'USD', '| top-of-the-line MacBook Pros');
defineKnownQuantity(3763, 'USD', '| months in an average Manhattan apartment in 2014');
defineKnownQuantity(18290, 'USD', '| sticker-priced 2015 Honda Civics');
defineKnownQuantity(100000, 'USD', '| rural 2-bedroom American homes');
defineKnownQuantity(1200000, 'USD', '| briefcases full of $100 bills');
defineKnownQuantity(1914000, 'USD', '| Bugatti Veyrons');
defineKnownQuantity(274000000, 'USD', '| Paul Cézanne\'s "The Card Players"');
defineKnownQuantity(10500000000, 'USD', '| times Mark Zuckerberg\'s 2013 earnings');
defineKnownQuantity(73500000000, 'USD', '| times Warren Buffett\'s 2014 net worth');
defineKnownQuantity(77608740000000, 'USD', '| times the total global GDP in 2014');

// Sort the quantities.
for (var unitShortName in KNOWN_QUANTITIES) {
  KNOWN_QUANTITIES[unitShortName].sort(function(a, b) {
    return a.quantity - b.quantity;
  });
}
<|endoftext|>


<commit_before>videojs.addLanguage("hu",{
 "Play": "Lejátszás",
 "Pause": "Szünet",
 "Current Time": "Aktuális időpont",
 "Duration Time": "Hossz",
 "Remaining Time": "Hátralévő idő",
 "Stream Type": "Adatfolyam típusa",
 "LIVE": "ÉLŐ",
 "Loaded": "Betöltve",
 "Progress": "Állapot",
 "Fullscreen": "Teljes képernyő",
 "Non-Fullscreen": "Normál méret",
 "Mute": "Némítás",
 "Unmuted": "Némítás kikapcsolva",
 "Playback Rate": "Lejátszási sebesség",
 "Subtitles": "Feliratok",
 "subtitles off": "Feliratok kikapcsolva",
 "Captions": "Magyarázó szöveg",
 "captions off": "Magyarázó szöveg kikapcsolva",
 "Chapters": "Fejezetek",
 "You aborted the video playback": "Leállította a lejátszást",
 "A network error caused the video download to fail part-way.": "Hálózati hiba miatt a videó részlegesen töltődött le.",
 "The video could not be loaded, either because the server or network failed or because the format is not supported.": "A videó nem tölthető be hálózati vagy kiszolgálói hiba miatt, vagy a formátuma nem támogatott.",
 "The video playback was aborted due to a corruption problem or because the video used features your browser did not support.": "A lejátszás adatsérülés miatt leállt, vagy a videó egyes tulajdonságait a böngészője nem támogatja.",
 "No compatible source was found for this video.": "Nincs kompatibilis forrás ehhez a videóhoz."
});<commit_msg>Delete hu.js<commit_after><|endoftext|>


<commit_before>//
// minigit.js tests
//
var minigit = require('../minigit'),
    should = require('should'),
    gutil = require('gulp-util'),
    sh = require('shelljs'),
    path = require('path'),
    _ = require('lodash');

require('mocha');

var repoInit = function () {
    process.env['GIT_WORK_TREE'] = path.resolve(__dirname, 'repo');
    process.env['GIT_DIR'] = path.resolve(process.env['GIT_WORK_TREE'], '.git');

    // console.log('GIT_WORK_TREE:', process.env['GIT_WORK_TREE']);
    // console.log('GIT_DIR:', process.env['GIT_DIR']);

    sh.rm('-rf', process.env['GIT_WORK_TREE']);
    sh.mkdir('-p', process.env['GIT_WORK_TREE']);

    sh.cp('-Rf', mkPath('fixtures/repo/*'.split('/')), process.env['GIT_WORK_TREE']);

    sh.exec('git init', { silent: true });
    sh.exec('git config user.email qa@gulp-urlrevs.com', { silent: true });
    sh.exec('git config user.name QA', { silent: true });
    sh.exec('git add -A', { silent: true });
    sh.exec('git commit -am "initial commit"', { silent: true });
};

var repoEnv = function() {
    // console.log( sh.ls('-R', process.env['GIT_WORK_TREE']) );
    // console.log('GIT_WORK_TREE:', process.env['GIT_WORK_TREE']);
    // console.log('GIT_DIR:', process.env['GIT_DIR']);
};

var repoClean = function() {
    sh.rm('-rf', process.env['GIT_WORK_TREE']);
    delete process.env['GIT_WORK_TREE'];
    delete process.env['GIT_DIR'];
};

var mkPath = function(items) {
    items.unshift(__dirname);

    return items.join(path.sep);
};

var repoAdd = function(src, dst, opts) {
    var from = mkPath(src.split("/")),
        to = mkPath(dst.split("/"));

    // console.log( 'from: ' +  from);
    // console.log( 'to  : ' +  to );

    sh.mkdir('-p', to);
    sh.cp('-f', from, to);
};

describe('minigit', function() {
    // -
    var options = {
        filter: '\\.(png|jpg)',
        branch: 'HEAD',
        path: 'root/i',
        abbrev: 6,
        message: 'commit changes (urlrevs)'
    };

    beforeEach(function(){
        repoInit();
    });

    afterEach(function(){
        repoClean();
    });

    describe('status()', function() {
        it('should raise exception on unknown repository', function() {
            // setup bogus repo
            process.env['GIT_DIR'] = path.resolve(__dirname, 'bogus');

            minigit.status(options, function(err) {
                should.exist(err);
                err.should.be.an.Error;
                err.message.should.match(/^Unable to get repository status!/);
            });
        });

        it('should not return uncommited changes', function() {
            minigit.status(options, function(err, changed) {
                should.not.exist(err);
                changed.should.be.eql([]);
            });
        });

        it('should not return uncommited changes after foo.txt was added', function(){
            repoAdd("fixtures/foo.txt", "repo");

            minigit.status(options, function(err, changed) {
                should.not.exist(err);
                changed.should.be.eql([]);
            });
        });

        it('should return uncommited changes after bar.png was added', function(){
            repoAdd("fixtures/bar.png", "repo/" + options.path);

            minigit.status(options, function(err, changed) {
                should.not.exist(err);
                changed.length.should.be.eql(1);
            });
        });

    });

    describe('lsTree()', function() {
        it('should raise exception on unknown repository', function() {
            // setup bogus repo
            process.env['GIT_DIR'] = path.resolve(__dirname, 'bogus');

            minigit.lsTree(options, function(err) {
                should.exist(err);
                err.should.be.an.Error;
                err.message.should.match(/^Unable to get repository tree!/);
            });
        });

        it('should return a tree object on valid repository', function() {
            minigit.lsTree(options, function(err, tree) {
                should.not.exist(err);
                tree.should.be.an.Object;
                tree.should.have.keys([ 'root/i/bar.jpg', 'root/i/foo.png' ]);
            });
        });
    });

    describe('add()', function() {
        it('should raise exception on unknown repository', function() {
            // setup bogus repo
            process.env['GIT_DIR'] = path.resolve(__dirname, 'bogus');

            minigit.add(options, function(err) {
                should.exist(err);
                err.should.be.an.Error;
                err.message.should.match(/^Unable to add files to repository!/);
            });
        });

        it('should be done w/o error on valid repository', function() {
            repoAdd("fixtures/bar.png", "repo/" + options.path);

            minigit.add(options, function(err) {
                should.not.exist(err);
            });
        });
    });

    describe('commit()', function() {
        var originalAdd = minigit.add;

        it('should raise exception on unknown repository', function() {

            repoAdd("fixtures/bar.png", "repo/" + options.path);
            minigit.add(options, function(){});

            // spoof MiniGit.add()
            minigit.add = function (params, cb) { return cb(null); };

            // setup bogus repo
            process.env['GIT_DIR'] = path.resolve(__dirname, 'bogus');

            minigit.commit(options, function(err) {
                should.exist(err);
                err.should.be.an.Error;
                err.message.should.match(/^Unable to commit changes!/);
            });
        });

        it('should be done w/o error on valid repository', function() {
            // restore MiniGit.add()
            minigit.add = originalAdd;

            repoAdd("fixtures/bar.png", "repo/" + options.path);

            minigit.commit(options, function(err) {
                should.not.exist(err);
            });
        });
    });
});
<commit_msg>clean up debug stuff<commit_after>//
// minigit.js tests
//
var minigit = require('../minigit'),
    should = require('should'),
    gutil = require('gulp-util'),
    sh = require('shelljs'),
    path = require('path'),
    _ = require('lodash');

require('mocha');

var repoInit = function () {
    process.env['GIT_WORK_TREE'] = path.resolve(__dirname, 'repo');
    process.env['GIT_DIR'] = path.resolve(process.env['GIT_WORK_TREE'], '.git');

    sh.rm('-rf', process.env['GIT_WORK_TREE']);
    sh.mkdir('-p', process.env['GIT_WORK_TREE']);

    sh.cp('-Rf', mkPath('fixtures/repo/*'.split('/')), process.env['GIT_WORK_TREE']);

    sh.exec('git init', { silent: true });
    sh.exec('git config user.email qa@gulp-urlrevs.com', { silent: true });
    sh.exec('git config user.name QA', { silent: true });
    sh.exec('git add -A', { silent: true });
    sh.exec('git commit -am "initial commit"', { silent: true });
};

var repoClean = function() {
    sh.rm('-rf', process.env['GIT_WORK_TREE']);
    delete process.env['GIT_WORK_TREE'];
    delete process.env['GIT_DIR'];
};

var mkPath = function(items) {
    items.unshift(__dirname);

    return items.join(path.sep);
};

var repoAdd = function(src, dst, opts) {
    var from = mkPath(src.split("/")),
        to = mkPath(dst.split("/"));

    sh.mkdir('-p', to);
    sh.cp('-f', from, to);
};

describe('minigit', function() {
    // -
    var options = {
        filter: '\\.(png|jpg)',
        branch: 'HEAD',
        path: 'root/i',
        abbrev: 6,
        message: 'commit changes (urlrevs)'
    };

    beforeEach(function(){
        repoInit();
    });

    afterEach(function(){
        repoClean();
    });

    describe('status()', function() {
        it('should raise exception on unknown repository', function() {
            // setup bogus repo
            process.env['GIT_DIR'] = path.resolve(__dirname, 'bogus');

            minigit.status(options, function(err) {
                should.exist(err);
                err.should.be.an.Error;
                err.message.should.match(/^Unable to get repository status!/);
            });
        });

        it('should not return uncommited changes', function() {
            minigit.status(options, function(err, changed) {
                should.not.exist(err);
                changed.should.be.eql([]);
            });
        });

        it('should not return uncommited changes after foo.txt was added', function(){
            repoAdd("fixtures/foo.txt", "repo");

            minigit.status(options, function(err, changed) {
                should.not.exist(err);
                changed.should.be.eql([]);
            });
        });

        it('should return uncommited changes after bar.png was added', function(){
            repoAdd("fixtures/bar.png", "repo/" + options.path);

            minigit.status(options, function(err, changed) {
                should.not.exist(err);
                changed.length.should.be.eql(1);
            });
        });

    });

    describe('lsTree()', function() {
        it('should raise exception on unknown repository', function() {
            // setup bogus repo
            process.env['GIT_DIR'] = path.resolve(__dirname, 'bogus');

            minigit.lsTree(options, function(err) {
                should.exist(err);
                err.should.be.an.Error;
                err.message.should.match(/^Unable to get repository tree!/);
            });
        });

        it('should return a tree object on valid repository', function() {
            minigit.lsTree(options, function(err, tree) {
                should.not.exist(err);
                tree.should.be.an.Object;
                tree.should.have.keys([ 'root/i/bar.jpg', 'root/i/foo.png' ]);
            });
        });
    });

    describe('add()', function() {
        it('should raise exception on unknown repository', function() {
            // setup bogus repo
            process.env['GIT_DIR'] = path.resolve(__dirname, 'bogus');

            minigit.add(options, function(err) {
                should.exist(err);
                err.should.be.an.Error;
                err.message.should.match(/^Unable to add files to repository!/);
            });
        });

        it('should be done w/o error on valid repository', function() {
            repoAdd("fixtures/bar.png", "repo/" + options.path);

            minigit.add(options, function(err) {
                should.not.exist(err);
            });
        });
    });

    describe('commit()', function() {
        var originalAdd = minigit.add;

        it('should raise exception on unknown repository', function() {

            repoAdd("fixtures/bar.png", "repo/" + options.path);
            minigit.add(options, function(){});

            // spoof MiniGit.add()
            minigit.add = function (params, cb) { return cb(null); };

            // setup bogus repo
            process.env['GIT_DIR'] = path.resolve(__dirname, 'bogus');

            minigit.commit(options, function(err) {
                should.exist(err);
                err.should.be.an.Error;
                err.message.should.match(/^Unable to commit changes!/);
            });
        });

        it('should be done w/o error on valid repository', function() {
            // restore MiniGit.add()
            minigit.add = originalAdd;

            repoAdd("fixtures/bar.png", "repo/" + options.path);

            minigit.commit(options, function(err) {
                should.not.exist(err);
            });
        });
    });
});
<|endoftext|>


<commit_before>/* eslint react/no-multi-comp: 0, react/prop-types: 0 */
import React from 'react';
import { shallow } from 'enzyme';
import { Label } from '../lib';

describe('Label', () => {
  it('should render children', () => {
    const wrapper = shallow(Yo!);

    expect(wrapper.text()).toBe('Yo!');
  });

  it('should render labels with default color', () => {
    const wrapper = shallow(Default Label);

    expect(wrapper.hasClass('label-default')).toBe(true);
  });

  it('should render Labels with other colors', () => {
    const wrapper = shallow(Danger Label);

    expect(wrapper.hasClass('label-danger')).toBe(true);
  });
});
<commit_msg>tests(Label): add test for pill prop<commit_after>/* eslint react/no-multi-comp: 0, react/prop-types: 0 */
import React from 'react';
import { shallow } from 'enzyme';
import { Label } from '../lib';

describe('Label', () => {
  it('should render children', () => {
    const wrapper = shallow(Yo!);

    expect(wrapper.text()).toBe('Yo!');
  });

  it('should render labels with default color', () => {
    const wrapper = shallow(Default Label);

    expect(wrapper.hasClass('label-default')).toBe(true);
  });

  it('should render Labels with other colors', () => {
    const wrapper = shallow(Danger Label);

    expect(wrapper.hasClass('label-danger')).toBe(true);
  });

  it('should render Labels as pills', () => {
    const wrapper = shallow(Pill Label);

    expect(wrapper.hasClass('label-pill')).toBe(true);
  });
});
<|endoftext|>


<commit_before>// import assert from 'assert';
'use strict';
import path from 'path'
import assert from 'assert';
import LogicExpressionParser from '../src/js/classes/Parse/LogicExpressionParser';

describe('LogicExpressionParser', function() {
  describe('#isWellformed()', function() {

    beforeEach(function() {
      this._parser = new LogicExpressionParser();
    });

    it('should detect a binary operator with only no operands is not well formed', function() {
      assert.strictEqual(this._parser.isWellformed('∧'), false);
    });

    it('should detect a binary operator with only one operand is not well formed', function() {
      assert.strictEqual(this._parser.isWellformed('a∧'), false);
    });

    it('should detect a binary operator with two operands is well formed', function() {
      assert.strictEqual(this._parser.isWellformed('a∧b'), true);
    });

    it('should be able to detect a unary operator with no operands is not well formed', function() {
      assert.strictEqual(this._parser.isWellformed('¬'), false);
    });

    it('should be able to detect a unary operator with one operand is well formed', function() {
      assert.strictEqual(this._parser.isWellformed('¬a'), true);
    });

    it('should be able to detect a unary operator with two operands is not well formed', function() {
      assert.strictEqual(this._parser.isWellformed('a¬a'), false);
    });

    it('should be able to detect the empty expression is well formed', function() {
      assert.strictEqual(this._parser.isWellformed(''), true);
    });
  })
});
<commit_msg>Add final tests for well formed<commit_after>// import assert from 'assert';
'use strict';
import path from 'path'
import assert from 'assert';
import LogicExpressionParser from '../src/js/classes/Parse/LogicExpressionParser';

describe('LogicExpressionParser', function() {
  beforeEach(function() {
    this._parser = new LogicExpressionParser();
  });

  describe('#isWellformed()', function() {

    it('should detect a binary operator with only no operands is not well formed', function() {
      assert.strictEqual(this._parser.isWellformed('∧'), false);
    });

    it('should detect a binary operator with only one operand is not well formed', function() {
      assert.strictEqual(this._parser.isWellformed('a∧'), false);
    });

    it('should detect a binary operator with two operands is well formed', function() {
      assert.strictEqual(this._parser.isWellformed('a∧b'), true);
    });

    it('should be able to detect a unary operator with no operands is not well formed', function() {
      assert.strictEqual(this._parser.isWellformed('¬'), false);
    });

    it('should be able to detect a unary operator with one operand is well formed', function() {
      assert.strictEqual(this._parser.isWellformed('¬a'), true);
    });

    it('should be able to detect a unary operator with two operands is not well formed', function() {
      assert.strictEqual(this._parser.isWellformed('a¬a'), false);
    });

    it('should be able to detect the empty expression is well formed', function() {
      assert.strictEqual(this._parser.isWellformed(''), true);
    });

    it('should be able to detect that complex expressions of well formed expressions are well formed', function() {
      assert.strictEqual(this._parser.isWellformed('¬(a∧b)∨(a∧b)'), true);
    });

    it('should be able to detect that complex expressions of not well formed expressions are not well formed', function() {
      assert.strictEqual(this._parser.isWellformed('¬(a∧∧b)∨(a∧b)'), false);
    });
  });

});
<|endoftext|>


<commit_before>"use strict";

var jadiTest = require("./src/testPlugIn.js").jadiTest();

jadiTest.run({
	id : "testPositive",
	path : "./test/jadiTest@SomeTest",
	testSuit : "Sometest",
	scope : "p"
},
{
	id : "testPositive2",
	path : "./test/jadiTest@SomeTest",
	testSuit : "Some test Else",
	scope : "p"
});<commit_msg>correct file pathes<commit_after>"use strict";

var jadiTest = require("../src/testPlugIn.js").jadiTest();

jadiTest.run({
	id : "testPositive",
	path : "./jadiTest@SomeTest",
	testSuit : "Sometest",
	scope : "p"
},
{
	id : "testPositive2",
	path : "./jadiTest@SomeTest",
	testSuit : "Some test Else",
	scope : "p"
});<|endoftext|>


<commit_before>/*
 * (C) Copyright 2015 Kurento (http://kurento.org/)
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl-2.1.html
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 */

/**
 * {@link WebRtcPeer} test suite.
 *
 *

 * Methods tested:
 *

 *
{@link WebRtcEndpoint#getLocalSessionDescriptor()}
 *

 *

 * Events tested:
 *

 *
{@link WebRtcEndpoint#addMediaSessionStartListener(MediaEventListener)}
 *

 * {@link HttpEndpoint#addMediaSessionTerminatedListener(MediaEventListener)}
 *

 *
 *
 * @author Jesús Leganés Combarro "piranna" (piranna@gmail.com)
 * @since 4.2.4
 *
 */

if(typeof QUnit == 'undefined')
{
  QUnit = require('qunit-cli');
  QUnit.load();

  kurentoUtils = require('..');

  require('./_common');
};

var WebRtcPeerRecvonly = kurentoUtils.WebRtcPeer.WebRtcPeerRecvonly;
var WebRtcPeerSendonly = kurentoUtils.WebRtcPeer.WebRtcPeerSendonly;
var WebRtcPeerSendrecv = kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv;

function getOscillatorMedia()
{
  var ac = new AudioContext();
  var osc = ac.createOscillator();
  var dest = ac.createMediaStreamDestination();
  osc.connect(dest);

  return dest.stream;
}

QUnit.module('WebRtcPeer');

QUnit.test('WebRtcPeerRecvonly', function(assert)
{
  var done = assert.async();

  assert.expect(1);

  var webRtcPeer = new WebRtcPeerRecvonly()

  function onerror(error)
  {
    webRtcPeer.dispose()

    _onerror(error)
  }

  webRtcPeer.on('error', onerror)
  webRtcPeer.on('sdpoffer', function(sdpOffer)
  {
    var offer = new RTCSessionDescription(
    {
      type: 'offer',
      sdp:  sdpOffer
    });

    var peerConnection = new RTCPeerConnection()

    peerConnection.setRemoteDescription(offer, function()
    {
      var stream = getOscillatorMedia()

      peerConnection.addStream(stream)

      peerConnection.createAnswer(function(answer)
      {
        peerConnection.setLocalDescription(answer, function()
        {
          webRtcPeer.processSdpAnswer(answer.sdp, function(error)
          {
            if(error) return onerror(error)

            var stream = this.getRemoteStream()
            assert.notEqual(stream, undefined, 'remote stream')

            this.dispose()
            done()
          })
        },
        onerror);
      },
      onerror);
    },
    onerror)
  })
});

QUnit.test('WebRtcPeerSendonly', function(assert)
{
  var done = assert.async();

  assert.expect(2);

  var webRtcPeer = new WebRtcPeerSendonly()

  function onerror(error)
  {
    webRtcPeer.dispose()

    _onerror(error)
  }

  webRtcPeer.on('error', onerror)
  webRtcPeer.on('sdpoffer', function(sdpOffer)
  {
    var stream = this.getLocalStream()
    assert.notEqual(stream, undefined, 'local stream')

    var offer = new RTCSessionDescription(
    {
      type: 'offer',
      sdp:  sdpOffer
    });

    var peerConnection = new RTCPeerConnection()

    peerConnection.setRemoteDescription(offer, function()
    {
      var stream = peerConnection.getRemoteStreams()[0]
      assert.notEqual(stream, undefined, 'peer remote stream')

      peerConnection.createAnswer(function(answer)
      {
        peerConnection.setLocalDescription(answer, function()
        {
          webRtcPeer.processSdpAnswer(answer.sdp, function(error)
          {
            if(error) return onerror(error)

            this.dispose()

            done()
          })
        },
        onerror);
      },
      onerror);
    },
    onerror)
  })
});

QUnit.test('WebRtcPeerSendrecv', function(assert)
{
  var done = assert.async();

  assert.expect(3);

  var webRtcPeer = new WebRtcPeerSendrecv()

  function onerror(error)
  {
    webRtcPeer.dispose()

    _onerror(error)
  }

  webRtcPeer.on('error', onerror)
  webRtcPeer.on('sdpoffer', function(sdpOffer)
  {
    var stream = this.getLocalStream()
    assert.notEqual(stream, undefined, 'local stream')

    var offer = new RTCSessionDescription(
    {
      type: 'offer',
      sdp:  sdpOffer
    });

    var peerConnection = new RTCPeerConnection()

    peerConnection.setRemoteDescription(offer, function()
    {
      var stream = peerConnection.getRemoteStreams()[0]
      assert.notEqual(stream, undefined, 'peer remote stream')

      var stream = getOscillatorMedia();

      peerConnection.addStream(stream)

      peerConnection.createAnswer(function(answer)
      {
        peerConnection.setLocalDescription(answer, function()
        {
          webRtcPeer.processSdpAnswer(answer.sdp, function(error)
          {
            if(error) return onerror(error)

            var stream = this.getRemoteStream()
            assert.notEqual(stream, undefined, 'remote stream')

            this.dispose()
            done()
          })
        },
        onerror);
      },
      onerror);
    },
    onerror)
  })
});

QUnit.test('videoEnabled', function(assert)
{
  var done = assert.async();

  assert.expect(3);

  var video   = document.getElementById('localVideo')
  var canvas  = document.getElementById('canvas')
  var context = canvas.getContext('2d');

  var options =
  {
    localVideo: video,
    mediaConstraints: {audio: false}
  }

  var webRtcPeer = new WebRtcPeerSendonly(options)

  function onerror(error)
  {
    webRtcPeer.dispose()

    _onerror(error)
  }

  webRtcPeer.on('error', onerror)
  webRtcPeer.on('sdpoffer', function(sdpoffer)
  {
    setTimeout(function()
    {
      canvas.width  = video.videoWidth;
      canvas.height = video.videoHeight;

      var x = video.videoWidth  / 2
      var y = video.videoHeight / 2

      context.drawImage(video, 0,0,video.videoWidth,video.videoHeight)
      assert.notPixelEqual(canvas, x,y, 0,0,0,0, 'enabled');

      webRtcPeer.videoEnabled = false

      setTimeout(function()
      {
        context.drawImage(video, 0,0,video.videoWidth,video.videoHeight)
        assert.pixelEqual(canvas, x,y, 0,0,0,255, 'disabled');

        webRtcPeer.videoEnabled = true

        setTimeout(function()
        {
          context.drawImage(video, 0,0,video.videoWidth,video.videoHeight)
          assert.notPixelEqual(canvas, x,y, 0,0,0,255, 'enabled again');

          done()
        }, 0)
      }, 0)
    }, 500)
  })
});
<commit_msg>Use syntetic audioStream on WebRtcPeer tests<commit_after>/*
 * (C) Copyright 2015 Kurento (http://kurento.org/)
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl-2.1.html
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 */

/**
 * {@link WebRtcPeer} test suite.
 *
 *

 * Methods tested:
 *

 *
{@link WebRtcEndpoint#getLocalSessionDescriptor()}
 *

 *

 * Events tested:
 *

 *
{@link WebRtcEndpoint#addMediaSessionStartListener(MediaEventListener)}
 *

 * {@link HttpEndpoint#addMediaSessionTerminatedListener(MediaEventListener)}
 *

 *
 *
 * @author Jesús Leganés Combarro "piranna" (piranna@gmail.com)
 * @since 4.2.4
 *
 */

if(typeof QUnit == 'undefined')
{
  QUnit = require('qunit-cli');
  QUnit.load();

  kurentoUtils = require('..');

  require('./_common');
};

var WebRtcPeerRecvonly = kurentoUtils.WebRtcPeer.WebRtcPeerRecvonly;
var WebRtcPeerSendonly = kurentoUtils.WebRtcPeer.WebRtcPeerSendonly;
var WebRtcPeerSendrecv = kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv;

function getOscillatorMedia()
{
  var ac = new AudioContext();
  var osc = ac.createOscillator();
  var dest = ac.createMediaStreamDestination();
  osc.connect(dest);

  return dest.stream;
}

QUnit.module('WebRtcPeer');

QUnit.test('WebRtcPeerRecvonly', function(assert)
{
  var done = assert.async();

  assert.expect(1);

  var webRtcPeer = new WebRtcPeerRecvonly()

  function onerror(error)
  {
    webRtcPeer.dispose()

    _onerror(error)
  }

  webRtcPeer.on('error', onerror)
  webRtcPeer.on('sdpoffer', function(sdpOffer)
  {
    var offer = new RTCSessionDescription(
    {
      type: 'offer',
      sdp:  sdpOffer
    });

    var peerConnection = new RTCPeerConnection()

    peerConnection.setRemoteDescription(offer, function()
    {
      var stream = getOscillatorMedia()

      peerConnection.addStream(stream)

      peerConnection.createAnswer(function(answer)
      {
        peerConnection.setLocalDescription(answer, function()
        {
          webRtcPeer.processSdpAnswer(answer.sdp, function(error)
          {
            if(error) return onerror(error)

            var stream = this.getRemoteStream()
            assert.notEqual(stream, undefined, 'remote stream')

            this.dispose()
            done()
          })
        },
        onerror);
      },
      onerror);
    },
    onerror)
  })
});

QUnit.test('WebRtcPeerSendonly', function(assert)
{
  var done = assert.async();

  assert.expect(2);

  var options =
  {
    audioStream: getOscillatorMedia()
  }

  var webRtcPeer = new WebRtcPeerSendonly(options)

  function onerror(error)
  {
    webRtcPeer.dispose()

    _onerror(error)
  }

  webRtcPeer.on('error', onerror)
  webRtcPeer.on('sdpoffer', function(sdpOffer)
  {
    var stream = this.getLocalStream()
    assert.notEqual(stream, undefined, 'local stream')

    var offer = new RTCSessionDescription(
    {
      type: 'offer',
      sdp:  sdpOffer
    });

    var peerConnection = new RTCPeerConnection()

    peerConnection.setRemoteDescription(offer, function()
    {
      var stream = peerConnection.getRemoteStreams()[0]
      assert.notEqual(stream, undefined, 'peer remote stream')

      peerConnection.createAnswer(function(answer)
      {
        peerConnection.setLocalDescription(answer, function()
        {
          webRtcPeer.processSdpAnswer(answer.sdp, function(error)
          {
            if(error) return onerror(error)

            this.dispose()

            done()
          })
        },
        onerror);
      },
      onerror);
    },
    onerror)
  })
});

QUnit.test('WebRtcPeerSendrecv', function(assert)
{
  var done = assert.async();

  assert.expect(3);

  var options =
  {
    audioStream: getOscillatorMedia()
  }

  var webRtcPeer = new WebRtcPeerSendrecv(options)

  function onerror(error)
  {
    webRtcPeer.dispose()

    _onerror(error)
  }

  webRtcPeer.on('error', onerror)
  webRtcPeer.on('sdpoffer', function(sdpOffer)
  {
    var stream = this.getLocalStream()
    assert.notEqual(stream, undefined, 'local stream')

    var offer = new RTCSessionDescription(
    {
      type: 'offer',
      sdp:  sdpOffer
    });

    var peerConnection = new RTCPeerConnection()

    peerConnection.setRemoteDescription(offer, function()
    {
      var stream = peerConnection.getRemoteStreams()[0]
      assert.notEqual(stream, undefined, 'peer remote stream')

      var stream = getOscillatorMedia();

      peerConnection.addStream(stream)

      peerConnection.createAnswer(function(answer)
      {
        peerConnection.setLocalDescription(answer, function()
        {
          webRtcPeer.processSdpAnswer(answer.sdp, function(error)
          {
            if(error) return onerror(error)

            var stream = this.getRemoteStream()
            assert.notEqual(stream, undefined, 'remote stream')

            this.dispose()
            done()
          })
        },
        onerror);
      },
      onerror);
    },
    onerror)
  })
});

QUnit.test('videoEnabled', function(assert)
{
  var done = assert.async();

  assert.expect(3);

  var video   = document.getElementById('localVideo')
  var canvas  = document.getElementById('canvas')
  var context = canvas.getContext('2d');

  var options =
  {
    localVideo: video,
    mediaConstraints: {audio: false}
  }

  var webRtcPeer = new WebRtcPeerSendonly(options)

  function onerror(error)
  {
    webRtcPeer.dispose()

    _onerror(error)
  }

  webRtcPeer.on('error', onerror)
  webRtcPeer.on('sdpoffer', function(sdpoffer)
  {
    setTimeout(function()
    {
      canvas.width  = video.videoWidth;
      canvas.height = video.videoHeight;

      var x = video.videoWidth  / 2
      var y = video.videoHeight / 2

      context.drawImage(video, 0,0,video.videoWidth,video.videoHeight)
      assert.notPixelEqual(canvas, x,y, 0,0,0,0, 'enabled');

      webRtcPeer.videoEnabled = false

      setTimeout(function()
      {
        context.drawImage(video, 0,0,video.videoWidth,video.videoHeight)
        assert.pixelEqual(canvas, x,y, 0,0,0,255, 'disabled');

        webRtcPeer.videoEnabled = true

        setTimeout(function()
        {
          context.drawImage(video, 0,0,video.videoWidth,video.videoHeight)
          assert.notPixelEqual(canvas, x,y, 0,0,0,255, 'enabled again');

          done()
        }, 0)
      }, 0)
    }, 500)
  })
});
<|endoftext|>


<commit_before>/*global describe, beforeEach, it*/
'use strict';

var path    = require('path');
var yeoman  = require('yeoman-generator');
var helpers = yeoman.test;
var assert  = yeoman.assert;
var createAppGenerator = require('../helpers/create-generator').createAppGenerator;

describe('Yeogurt generator using Styles', function () {
    beforeEach(function (done) {
        helpers.testDirectory(path.join(__dirname, 'temp'), function (err) {
            if (err) {
                return done(err);
            }

            this.app = createAppGenerator();

            done();
        }.bind(this));
    });
    describe('With CSS', function () {
        it('Creates expected files', function (done) {
            var expected = [
                'client/styles/main.css',
                'grunt/config/optimize/cssmin.js'
            ];

            helpers.mockPrompt(this.app, {
                cssOption: 'css'
            });
            this.app.run([], function () {
                assert.file(expected);
                done();
            });
        });
    });
    describe('With Sass', function () {
        it('Creates expected files', function (done) {
            var expected = [
                'client/',
                'client/styles',
                'client/styles/main.scss',
                'grunt/',
                'grunt/config',
                'grunt/config/compile/sass.js'
            ];

            helpers.mockPrompt(this.app, {
                cssOption: 'sass'
            });
            this.app.run([], function () {
                assert.file(expected);
                done();
            });
        });
        describe('With Sass (not Scss) syntax', function () {
            it('Creates expected content', function (done) {
                var expected = [
                    'client/',
                    'client/styles',
                    'client/styles/main.sass',
                    'grunt/',
                    'grunt/config',
                    'grunt/config/compile/sass.js'
                ];
                var fileContentToTest = [
                    ['grunt/config/compile/sass.js', /\.sass/i],
                    ['grunt/config/docs/kss.js', /main\.sass/i]
                ];

                helpers.mockPrompt(this.app, {
                    cssOption: 'sass',
                    sassSyntax: 'sass',
                });
                this.app.run([], function () {
                    assert.file(expected);
                    assert.fileContent(fileContentToTest);
                    done();
                });
            });
        });
    });
    describe('With Less', function () {
        it('Creates expected files', function (done) {
            var expected = [
                'client/',
                'client/styles',
                'client/styles/main.less',
                'grunt/',
                'grunt/config',
                'grunt/config/compile/less.js'
            ];
            var fileContentToTest = [
                ['package.json', /less/i]
            ];

            helpers.mockPrompt(this.app, {
                cssOption: 'less'
            });
            this.app.run([], function () {
                assert.file(expected);
                assert.fileContent(fileContentToTest);
                done();
            });
        });
    });
    describe('With Stylus', function () {
        it('Creates expected files', function (done) {
            var expected = [
                'client/',
                'client/styles',
                'client/styles/main.styl',
                'grunt/',
                'grunt/config',
                'grunt/config/compile/stylus.js'
            ];

            helpers.mockPrompt(this.app, {
                cssOption: 'stylus',
                useBootstrap: false,
                useFoundation: false
            });
            this.app.run([], function () {
                assert.file(expected);
                done();
            });
        });
    });
});
<commit_msg>fixed unit test<commit_after>/*global describe, beforeEach, it*/
'use strict';

var path    = require('path');
var yeoman  = require('yeoman-generator');
var helpers = yeoman.test;
var assert  = yeoman.assert;
var createAppGenerator = require('../helpers/create-generator').createAppGenerator;

describe('Yeogurt generator using Styles', function () {
    beforeEach(function (done) {
        helpers.testDirectory(path.join(__dirname, 'temp'), function (err) {
            if (err) {
                return done(err);
            }

            this.app = createAppGenerator();

            done();
        }.bind(this));
    });
    describe('With CSS', function () {
        it('Creates expected files', function (done) {
            var expected = [
                'client/styles/main.css',
                'grunt/config/optimize/cssmin.js'
            ];

            helpers.mockPrompt(this.app, {
                cssOption: 'css'
            });
            this.app.run([], function () {
                assert.file(expected);
                done();
            });
        });
    });
    describe('With Sass', function () {
        it('Creates expected files', function (done) {
            var expected = [
                'client/',
                'client/styles',
                'client/styles/main.scss',
                'grunt/',
                'grunt/config',
                'grunt/config/compile/sass.js'
            ];

            helpers.mockPrompt(this.app, {
                cssOption: 'sass'
            });
            this.app.run([], function () {
                assert.file(expected);
                done();
            });
        });
        describe('With Sass (not Scss) syntax', function () {
            it('Creates expected content', function (done) {
                var expected = [
                    'client/',
                    'client/styles',
                    'client/styles/main.sass',
                    'grunt/',
                    'grunt/config',
                    'grunt/config/compile/sass.js'
                ];
                var fileContentToTest = [
                    ['grunt/config/docs/kss.js', /main\.sass/i]
                ];

                helpers.mockPrompt(this.app, {
                    cssOption: 'sass',
                    sassSyntax: 'sass',
                });
                this.app.run([], function () {
                    assert.file(expected);
                    assert.fileContent(fileContentToTest);
                    done();
                });
            });
        });
    });
    describe('With Less', function () {
        it('Creates expected files', function (done) {
            var expected = [
                'client/',
                'client/styles',
                'client/styles/main.less',
                'grunt/',
                'grunt/config',
                'grunt/config/compile/less.js'
            ];
            var fileContentToTest = [
                ['package.json', /less/i]
            ];

            helpers.mockPrompt(this.app, {
                cssOption: 'less'
            });
            this.app.run([], function () {
                assert.file(expected);
                assert.fileContent(fileContentToTest);
                done();
            });
        });
    });
    describe('With Stylus', function () {
        it('Creates expected files', function (done) {
            var expected = [
                'client/',
                'client/styles',
                'client/styles/main.styl',
                'grunt/',
                'grunt/config',
                'grunt/config/compile/stylus.js'
            ];

            helpers.mockPrompt(this.app, {
                cssOption: 'stylus',
                useBootstrap: false,
                useFoundation: false
            });
            this.app.run([], function () {
                assert.file(expected);
                done();
            });
        });
    });
});
<|endoftext|>


<commit_before>
/*global describe, it, define, expect*/
/*jslint indent: 2, todo: true */

define(['blame'], function (blame) {
  'use strict';

  // Global utils
  function empty() { return; }
  var unused = empty,
    used = empty;

  used(unused);

  var wrap = blame.wrap,
    Label = blame.Label,
    fun = blame.fun,
    Num = blame.Num;

  function identity (x) { return x; }

  function gen_const (x) {
    return function () {
      return x;
    };
  }

  function closed (f) {
    return function () {
      var args = Array.prototype.slice.call(arguments || []);
      return function () {
        return f.apply(undefined, args);
      };
    };
  }

  // Some constants for testing
  var p = new Label(),
    q = new Label();

  describe('Blame module', function () {
    it('should be imported', function () {
      used(expect(blame).to.exist);
    });

    describe('blame labels', function () {
      it('should initialize properly', function () {
        var l1 = new Label(),
          l2 = new Label();
        expect(l1.label).to.not.equal('label');
        expect(l1.label).to.not.equal(l2.label);
      });

      it('should negate properly', function () {
        var l1 = new Label(),
          l2 = l1.negated();
        expect(l1.label).to.equal(l2.label);
        expect(l1.status).to.not.equal(l2.status);
      });
    });
  });

  describe('wrapping', function () {
    describe('basic types', function () {
        var type = fun(Num, Num),
          bad = gen_const('a'),
          wrapped_good = wrap(identity, p, q, type, type),
          wrapped_bad = wrap(bad, p, q, type, type),
          closed_good = closed(wrapped_good),
          closed_bad = closed(wrapped_bad);

      it('should permit proper types', function () {
          expect(closed_good(1)).not.to.throw();
      });

      it('should reject improper types', function () {
        expect(closed_bad(1)).to.throw(p.msg());
        expect(closed_bad('a')).to.throw(q.msg());
        expect(closed_good('a')).to.throw(q.msg());
      });
    });

  });
});

// vim: set ts=2 sw=2 sts=2 et :
<commit_msg>Add basic types<commit_after>
/*global describe, it, define, expect*/
/*jslint indent: 2, todo: true */

define(['blame'], function (blame) {
  'use strict';

  // Global utils
  function empty() { return; }
  var unused = empty,
    used = empty;

  used(unused);

  var wrap = blame.wrap,
    Label = blame.Label,
    fun = blame.fun,
    Num = blame.Num;

  function identity (x) { return x; }

  function gen_const (x) {
    return function () {
      return x;
    };
  }

  function closed (f) {
    return function () {
      var args = Array.prototype.slice.call(arguments || []);
      return function () {
        return f.apply(undefined, args);
      };
    };
  }

  // Some constants for testing
  var p = new Label(),
    q = new Label();

  describe('Blame module', function () {
    it('should be imported', function () {
      used(expect(blame).to.exist);
    });

    describe('blame labels', function () {
      it('should initialize properly', function () {
        var l1 = new Label(),
          l2 = new Label();
        expect(l1.label).to.not.equal('label');
        expect(l1.label).to.not.equal(l2.label);
      });

      it('should negate properly', function () {
        var l1 = new Label(),
          l2 = l1.negated();
        expect(l1.label).to.equal(l2.label);
        expect(l1.status).to.not.equal(l2.status);
      });
    });
  });

  describe('wrapping', function () {
    function wrapped(value, p, q, A, B) {
      return function() {
        return wrap(value, p, q, A, B);
      };
    }

    describe('basic types', function () {
      it('should permit proper types', function () {
        expect(wrapped(1, p, q, Num, Num)).not.to.throw();
      });

      it('should reject improper types', function () {
        expect(wrapped('a', p, q, Num, Num)).to.throw(p);
      });
    });

    describe('functions', function () {
        var type = fun(Num, Num),
          bad = gen_const('a'),
          wrapped_good = wrap(identity, p, q, type, type),
          wrapped_bad = wrap(bad, p, q, type, type),
          closed_good = closed(wrapped_good),
          closed_bad = closed(wrapped_bad);

      it('should permit proper types', function () {
          expect(closed_good(1)).not.to.throw();
      });

      it('should reject improper types', function () {
        expect(closed_bad(1)).to.throw(p.msg());
        expect(closed_bad('a')).to.throw(q.msg());
        expect(closed_good('a')).to.throw(q.msg());
      });
    });

  });
});

// vim: set ts=2 sw=2 sts=2 et :
<|endoftext|>


<commit_before>"use strict";

var fs     = require("fs"),
    path   = require("path"),
    assert = require("assert"),

    browserify = require("browserify"),
    from       = require("from2-string"),

    plugin = require("../src/browserify"),

    bundle  = require("./lib/bundle"),
    compare = require("./lib/compare-files");

describe("modular-css", function() {
    describe("browserify plugin", function() {
        before(function() {
            require("shelljs").rm("-rf", "./test/output/*.*");
        });

        it("should error if an invalid extension is applied", function(done) {
            var build = browserify();

            build.on("error", function(err) {
                assert.equal(err, "Missing or invalid \"ext\" option: false");

                done();
            });

            build.plugin(plugin, { ext : false });
        });

        it("should error on invalid CSS", function(done) {
            var build  = browserify({
                    entries : from("require('./invalid.css');"),
                    basedir : "./test/specimens"
                }),
                errors = 0;

            build.plugin(plugin);

            build.bundle(function(err) {
                if(++errors === 2) {
                    return done();
                }

                assert(err);
                assert.equal(err.name, "CssSyntaxError");
                assert.equal(err.reason, "Invalid composes reference");
            });
        });

        it("should replace require() calls with the exported identifiers", function(done) {
            var build = browserify({
                    entries : from("require('./simple.css');"),
                    basedir : "./test/specimens"
                });

            build.plugin(plugin);

            bundle(build, function(out) {
                assert(
                    out.indexOf(fs.readFileSync("./test/results/browserify/export-identifiers.js", "utf8")) > -1
                );

                done();
            });
        });

        it("should correctly rewrite urls based on the destination file", function(done) {
            var build = browserify({
                    entries : from("require('./relative.css');"),
                    basedir : "./test/specimens"
                });

            build.plugin(plugin, {
                css : "./test/output/browserify/relative.css"
            });

            bundle(build, function() {
                compare.results("browserify/relative.css");

                done();
            });
        });

        it("should use the specified prefix", function(done) {
            var build = browserify({
                    entries : from("require('./simple.css');"),
                    basedir : "./test/specimens"
                });

            build.plugin(plugin, {
                css    : "./test/output/browserify/prefix.css",
                prefix : "prefix"
            });

            bundle(build, function() {
                compare.results("browserify/prefix.css");

                done();
            });
        });

        it("should use the specified namer function", function(done) {
            var build = browserify({
                    entries : from("require('./keyframes.css');"),
                    basedir : "./test/specimens"
                });

            build.plugin(plugin, {
                css   : "./test/output/browserify/namer-fn.css",
                namer : function(file, selector) {
                    return path.basename(file, path.extname(file)) + "-" + selector;
                }
            });

            bundle(build, function() {
                compare.results("browserify/namer-fn.css");

                done();
            });
        });

        it("should include all CSS dependencies in output css", function(done) {
            var build = browserify({
                    entries : from("require('./start.css');"),
                    basedir : "./test/specimens"
                });

            build.plugin(plugin, { css : "./test/output/browserify/include-css-deps.css" });

            bundle(build, function(out) {
                assert(out.indexOf(fs.readFileSync("./test/results/browserify/include-css-deps.js", "utf8")) > -1);

                compare.results("browserify/include-css-deps.css");

                done();
            });
        });

        it("should write out the complete exported identifiers when `json` is specified", function(done) {
            var build = browserify({
                    entries : from("require('./simple.css');"),
                    basedir : "./test/specimens"
                });

            build.plugin(plugin, { json : "./test/output/browserify/export-all-identifiers.json" });

            bundle(build, function() {
                compare.results("browserify/export-all-identifiers.json");

                done();
            });
        });

        it("should not include duplicate files in the output multiple times", function(done) {
            var build = browserify({
                    entries : from("require('./start.css'); require('./local.css');"),
                    basedir : "./test/specimens"
                });

            build.plugin(plugin, { css : "./test/output/browserify/avoid-duplicates.css" });

            bundle(build, function(out) {
                assert(out.indexOf(fs.readFileSync("./test/results/browserify/avoid-duplicates-local.js", "utf8")) > -1);
                assert(out.indexOf(fs.readFileSync("./test/results/browserify/avoid-duplicates-start.js", "utf8")) > -1);

                compare.results("browserify/avoid-duplicates.css");

                done();
            });
        });
    });
});
<commit_msg>Better after() usage<commit_after>"use strict";

var fs     = require("fs"),
    path   = require("path"),
    assert = require("assert"),

    browserify = require("browserify"),
    from       = require("from2-string"),

    plugin = require("../src/browserify"),

    bundle  = require("./lib/bundle"),
    compare = require("./lib/compare-files");

describe("modular-css", function() {
    describe("browserify plugin", function() {
        after(function(done) {
            require("rimraf")("./test/output/browserify", done);
        });

        it("should error if an invalid extension is applied", function(done) {
            var build = browserify();

            build.on("error", function(err) {
                assert.equal(err, "Missing or invalid \"ext\" option: false");

                done();
            });

            build.plugin(plugin, { ext : false });
        });

        it("should error on invalid CSS", function(done) {
            var build  = browserify({
                    entries : from("require('./invalid.css');"),
                    basedir : "./test/specimens"
                }),
                errors = 0;

            build.plugin(plugin);

            build.bundle(function(err) {
                if(++errors === 2) {
                    return done();
                }

                assert(err);
                assert.equal(err.name, "CssSyntaxError");
                assert.equal(err.reason, "Invalid composes reference");
            });
        });

        it("should replace require() calls with the exported identifiers", function(done) {
            var build = browserify({
                    entries : from("require('./simple.css');"),
                    basedir : "./test/specimens"
                });

            build.plugin(plugin);

            bundle(build, function(out) {
                assert(
                    out.indexOf(fs.readFileSync("./test/results/browserify/export-identifiers.js", "utf8")) > -1
                );

                done();
            });
        });

        it("should correctly rewrite urls based on the destination file", function(done) {
            var build = browserify({
                    entries : from("require('./relative.css');"),
                    basedir : "./test/specimens"
                });

            build.plugin(plugin, {
                css : "./test/output/browserify/relative.css"
            });

            bundle(build, function() {
                compare.results("browserify/relative.css");

                done();
            });
        });

        it("should use the specified prefix", function(done) {
            var build = browserify({
                    entries : from("require('./simple.css');"),
                    basedir : "./test/specimens"
                });

            build.plugin(plugin, {
                css    : "./test/output/browserify/prefix.css",
                prefix : "prefix"
            });

            bundle(build, function() {
                compare.results("browserify/prefix.css");

                done();
            });
        });

        it("should use the specified namer function", function(done) {
            var build = browserify({
                    entries : from("require('./keyframes.css');"),
                    basedir : "./test/specimens"
                });

            build.plugin(plugin, {
                css   : "./test/output/browserify/namer-fn.css",
                namer : function(file, selector) {
                    return path.basename(file, path.extname(file)) + "-" + selector;
                }
            });

            bundle(build, function() {
                compare.results("browserify/namer-fn.css");

                done();
            });
        });

        it("should include all CSS dependencies in output css", function(done) {
            var build = browserify({
                    entries : from("require('./start.css');"),
                    basedir : "./test/specimens"
                });

            build.plugin(plugin, { css : "./test/output/browserify/include-css-deps.css" });

            bundle(build, function(out) {
                assert(out.indexOf(fs.readFileSync("./test/results/browserify/include-css-deps.js", "utf8")) > -1);

                compare.results("browserify/include-css-deps.css");

                done();
            });
        });

        it("should write out the complete exported identifiers when `json` is specified", function(done) {
            var build = browserify({
                    entries : from("require('./simple.css');"),
                    basedir : "./test/specimens"
                });

            build.plugin(plugin, { json : "./test/output/browserify/export-all-identifiers.json" });

            bundle(build, function() {
                compare.results("browserify/export-all-identifiers.json");

                done();
            });
        });

        it("should not include duplicate files in the output multiple times", function(done) {
            var build = browserify({
                    entries : from("require('./start.css'); require('./local.css');"),
                    basedir : "./test/specimens"
                });

            build.plugin(plugin, { css : "./test/output/browserify/avoid-duplicates.css" });

            bundle(build, function(out) {
                assert(out.indexOf(fs.readFileSync("./test/results/browserify/avoid-duplicates-local.js", "utf8")) > -1);
                assert(out.indexOf(fs.readFileSync("./test/results/browserify/avoid-duplicates-start.js", "utf8")) > -1);

                compare.results("browserify/avoid-duplicates.css");

                done();
            });
        });
    });
});
<|endoftext|>