Add class UserContext

This commit is contained in:
darthjee
2017-07-24 22:35:05 +02:00
parent 4cce7263c4
commit b0aac6b852
8 changed files with 139 additions and 18 deletions

View File

@@ -0,0 +1,54 @@
describe("UserContext", function() {
it("Behaves just like an plain object", function() {
var context = new jasmineUnderTest.UserContext(),
properties = [];
for (var prop in context) {
if (obj.hasOwnProperty(prop)) {
properties.push(prop);
}
}
expect(properties).toEqual([]);
});
describe('.fromExisting', function() {
describe('when using an already built context as model', function() {
beforeEach(function() {
this.context = new jasmineUnderTest.UserContext();
this.context.key = 'value';
this.clonned = jasmineUnderTest.UserContext.fromExisting(this.context);
});
it('returns a clonned object', function() {
expect(this.clonned).toEqual(this.context);
});
it('does not return the same object', function() {
expect(this.clonned).not.toBe(this.context);
});
});
describe('when using a regular object as parameter', function() {
beforeEach(function() {
this.context = {};
this.value = 'value'
this.context.key = this.value;
this.clonned = jasmineUnderTest.UserContext.fromExisting(this.context);
});
it('returns an object with the same attributes', function() {
expect(this.clonned.key).toEqual(this.value);
});
it('does not return the same object', function() {
expect(this.clonned).not.toBe(this.context);
});
it('returns an UserContext', function() {
expect(this.clonned.constructor).toBe(jasmineUnderTest.UserContext);
});
});
});
});