Example #1
0
var Promisy = typeof document === 'object' ? require('promisy') : require('../lib/promisy');
var test = require('simple-test');

var promisy = new Promisy;

test('promisy will call next callback asynchronously', function (done) {
  var picture = {};
  var i = 0;

  promisy(function (next) {
    next();
    i++;
    test.eq(i, 1);
    console.log(i, 'see me first');
  }).then(function (next) {
    next();
    i++;
    test.eq(i, 2);
    console.log(i, 'see me second');
  }).then(function (next) {
    i++;
    test.eq(i, 3);
    console.log(i, 'see me third');
    done();
  });
});
Example #2
0
 emails.forEach(function (email) {
   test('is email: ' + email, function () {
     test.ok(email.match(reges.email));
   });
 });
Example #3
0
 notEmails.forEach(function (notEmail) {
   test('not email: ' + notEmail, function () {
     test.notOk(notEmail.match(reges.email));
   });
 });
Example #4
0
var reges = require('../index');
var test = require('simple-test');

test('reges.url', function () {
  var emails = [
    '*****@*****.**'
  ];

  emails.forEach(function (email) {
    test('is email: ' + email, function () {
      test.ok(email.match(reges.email));
    });
  });

  var notEmails = [
    'word'
  ];

  notEmails.forEach(function (notEmail) {
    test('not email: ' + notEmail, function () {
      test.notOk(notEmail.match(reges.email));
    });
  });
});
var eventy = typeof document === 'object' ? require('eventy') : require('../index');
var test = require('simple-test');

var object = eventy({});

test('eventy.on will register multiple callbacks', function (done) {
  function onChange1() {
    console.log('onChange1');
  }

  function onChange2() {
    console.log('onChange2');
    done();
  }

  object.on('change', onChange1);
  object.on('change', onChange2);

  object.trigger('change');
});
Example #6
0
var test = require('simple-test');
var pageInfo = require('../index');

var google = 'google.com';
var baidu = 'www.baidu.com';
var designmodo = 'http://designmodo.com/long-shadows-design/';
var stackoverflow = 'http://stackoverflow.com/questions/18881982/how-can-i-get-all-the-doc-ids-in-mongodb/18883039?noredirect=1#comment27890387_18883039';
var mobify = 'http://www.mobify.com/blog/beginners-guide-to-http-cache-headers/';

test(google, function (done) {
  pageInfo(google, function (page) {
    console.log('icon', page.icon())
    console.log('favicon', page.favicon())
    console.log('shortcutIcon', page.shortcutIcon())
    console.log('title', page.title())
    console.log('thumbnail', page.thumbnail())
    console.log('firstImg', page.firstImg())
    done();
  }, function (err) {
    console.log('err', err);
  });
});

test(baidu, function (done) {
  pageInfo(baidu, function (page) {
    console.log('icon', page.icon())
    console.log('favicon', page.favicon())
    console.log('shortcutIcon', page.shortcutIcon())
    console.log('title', page.title())
    console.log('thumbnail', page.thumbnail())
    console.log('firstImg', page.firstImg())