JSFiddle - React, Tailwind, and code Playground

by reyuto

HTML

<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.12.0.css">
<script src="http://code.jquery.com/qunit/qunit-1.12.0.js"></script>
<script src="http://sinonjs.org/releases/sinon-1.7.3.js"></script>
<script src="http://sinonjs.org/releases/sinon-qunit-1.0.0.js"></script>
<div id="qunit"></div>
<div id="qunit-fixture"></div>

JavaScript

obj = {
            method: function (param) {}
        };

        function foo() {
            obj.method(1);
            obj.method(2);
            obj.method(3);
        }

        mock = sinon.mock(obj);

        QUnit.test('method is called with 1', function () {
            var expectation1 = mock.expects('method').once().withExactArgs(1);
            var expectation2 = mock.expects('method').atLeast(2);
            foo();
            expectation1.verify();
            expectation2.verify();
        });

        QUnit.test('method is called with 2', function () {
            var expectation1 = mock.expects('method').atLeast(1);
            var expectation2 = mock.expects('method').once().withExactArgs(2);
            var expectation3 = mock.expects('method').atLeast(1);
            foo();
            expectation1.verify();
            expectation2.verify();
            expectation3.verify();
        });

        QUnit.test('method is called with 3', function () {
            var expectation1 = mock.expects('method').once().withExactArgs(3);
            var expectation2 = mock.expects('method').atLeast(2);
            foo();
            expectation1.verify();
            expectation2.verify();
        });