import { assert } from "chai"
import { Session } from "../src/session.js"

var Cookie = require('js-cookie');
var sinon = require("sinon");

describe("Session", () => {

	it('can create', () => {
		var session = new Session;
		assert.instanceOf(session, Session);
	});

	it('reads the saved variant from a cookie', () => {
		var mock = sinon.mock(Cookie);
		mock.expects("get").once().returns(undefined);

		var session = new Session;
		assert.isUndefined(session.variant('experiment-1'));
	});

	it('saves the variant to a cookie', () => {
		var experiment = 'experiment-1';
		var variant = 'variant-1';

		var mock = sinon.mock(Cookie);
		mock.expects("set").once().withArgs(experiment, variant);

		var session = new Session;
		session.setVariant(experiment, variant);
	});

})

@@ -482,16 +482,34 @@
 nt-1'));
+%0A%0A%09%09mock.verify();
 %0A%09%7D);%0A%0A%09
@@ -782,16 +782,34 @@
 ariant);
+%0A%0A%09%09mock.verify();
 %0A%09%7D);%0A%0A%7D

check all mock expectations