cocalc/src / smc-project / node_modules / forever-monitor / node_modules / utile / test / utile-test.js
50655 views/*1* utile-test.js: Tests for `utile` module.2*3* (C) 2011, Nodejitsu Inc.4* MIT LICENSE5*6*/78var assert = require('assert'),9vows = require('vows'),10utile = require('../lib');1112var obj1, obj2;1314obj1 = {15foo: true,16bar: {17bar1: true,18bar2: 'bar2'19}20};2122obj2 = {23baz: true,24buzz: 'buzz'25};26obj2.__defineGetter__('bazz', function () {27return 'bazz';28});2930vows.describe('utile').addBatch({31"When using utile": {32"it should have the same methods as the `util` module": function () {33Object.keys(require('util')).forEach(function (fn) {34if (fn !== 'inspect') {35assert.isFunction(utile[fn]);36}37});38},39"it should have the correct methods defined": function () {40assert.isFunction(utile.mixin);41assert.isFunction(utile.clone);42assert.isFunction(utile.rimraf);43assert.isFunction(utile.mkdirp);44assert.isFunction(utile.cpr);45},46"the mixin() method": function () {47var mixed = utile.mixin({}, obj1, obj2);48assert.isTrue(mixed.foo);49assert.isObject(mixed.bar);50assert.isTrue(mixed.baz);51assert.isString(mixed.buzz);52assert.isTrue(!!mixed.__lookupGetter__('bazz'));53assert.isString(mixed.bazz);54},55"the clone() method": function () {56var clone = utile.clone(obj1);57assert.isTrue(clone.foo);58assert.isObject(clone.bar);59assert.notStrictEqual(obj1, clone);60},61"the createPath() method": function () {62var x = {},63r = Math.random();6465utile.createPath(x, ['a','b','c'], r)66assert.equal(x.a.b.c, r)67}68}69}).export(module);70717273