scope get all

This commit is contained in:
harttle
2016-06-26 13:16:34 +08:00
parent a482b4abe5
commit 82a6a72013
3 changed files with 18 additions and 4 deletions
+10 -3
View File
@@ -5,18 +5,25 @@ var expect = chai.expect;
var Scope = require('../src/scope.js');
describe('scope', function() {
var scope;
var scope, ctx;
beforeEach(function(){
scope = Scope.factory({
ctx = {
foo: 'bar',
bar: ['a', {b: [1, 2]}]
});
};
scope = Scope.factory(ctx);
});
it('should get property', function() {
scope.get('foo').should.equal('bar');
});
it('should get all property', function() {
scope.get().should.deep.equal(ctx);
expect(scope.get('')).to.equal(undefined);
expect(scope.get(false)).to.equal(undefined);
});
it('should set property', function() {
scope.set('foo', 'FOO');
scope.get('foo').should.equal('FOO');