UNPKG

2.2 kBJavaScriptView Raw
1var expect = require('expect.js');
2var assert = require('better-assert');
3var sinon = require('sinon');
4
5describe('console.table', function () {
6 beforeEach(function () {
7 // make sure the module is loaded without caching
8 delete require.cache[require.resolve('../index')];
9 });
10
11 afterEach(function () {
12 delete console.table;
13 });
14
15 it('fills missing method', function () {
16 expect(console.table).to.be(undefined);
17 });
18
19 it('installs html method', function () {
20 require('../index');
21 expect(typeof console.table).to.be('function');
22 });
23
24 it('logs simple string', function () {
25 require('../index');
26 sinon.spy(console, 'log');
27 console.table('foo');
28 assert(console.log.firstCall.calledWith('foo'));
29 console.log.restore();
30 });
31
32 it('logs several strings separately', function () {
33 require('../index');
34 sinon.spy(console, 'log');
35 console.table('foo', 'bar');
36 assert(console.log.firstCall.calledWith('foo'));
37 assert(console.log.secondCall.calledWith('bar'));
38 console.log.restore();
39 });
40
41/*
42 it('calls console.log ultimately', function () {
43 require('../index');
44 sinon.spy(console, 'log');
45 var str = '<h1>hi</h1>';
46 console.html(str);
47 expect(console.log.callCount).to.be(1);
48 expect(console.log.calledWith(str)).to.be(true);
49 console.log.restore();
50 });
51
52 it('calls console.log with value of html()', function () {
53 require('../index');
54 sinon.spy(console, 'log');
55 console.html({
56 html: function () {
57 return 'foo';
58 }
59 });
60 expect(console.log.calledWith('foo')).to.be(true);
61 console.log.restore();
62 });
63
64 it('calls console.log with value of innerHTML', function () {
65 require('../index');
66 sinon.spy(console, 'log');
67 console.html({
68 innerHTML: 'foo'
69 });
70 expect(console.log.calledWith('foo')).to.be(true);
71 console.log.restore();
72 });
73
74 it('logs nothing if no html found', function () {
75 require('../index');
76 sinon.spy(console, 'log');
77 console.html({
78 other: 'foo'
79 });
80 expect(console.log.calledWith('foo')).to.be(false);
81 expect(console.log.called).to.be(false);
82 console.log.restore();
83 });
84*/
85});