"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/defaults/test.js" (8 Mar 2017, 1050 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 var defaults = require('./'),
    2     test = require('tap').test;
    3 
    4 test("ensure options is an object", function(t) {
    5   var options = defaults(false, { a : true });
    6   t.ok(options.a);
    7   t.end()
    8 });
    9 
   10 test("ensure defaults override keys", function(t) {
   11   var result = defaults({}, { a: false, b: true });
   12   t.ok(result.b, 'b merges over undefined');
   13   t.equal(result.a, false, 'a merges over undefined');
   14   t.end();
   15 });
   16 
   17 test("ensure defined keys are not overwritten", function(t) {
   18   var result = defaults({ b: false }, { a: false, b: true });
   19   t.equal(result.b, false, 'b not merged');
   20   t.equal(result.a, false, 'a merges over undefined');
   21   t.end();
   22 });
   23 
   24 test("ensure defaults clone nested objects", function(t) {
   25   var d = { a: [1,2,3], b: { hello : 'world' } };
   26   var result = defaults({}, d);
   27   t.equal(result.a.length, 3, 'objects should be clones');
   28   t.ok(result.a !== d.a, 'objects should be clones');
   29 
   30   t.equal(Object.keys(result.b).length, 1, 'objects should be clones');
   31   t.ok(result.b !== d.b, 'objects should be clones');
   32   t.end();
   33 });
   34