2015-05-22 09:08:29 +08:00
|
|
|
_ = require 'underscore'
|
|
|
|
NamespaceStore = require '../../src/flux/stores/namespace-store'
|
|
|
|
|
|
|
|
describe "NamespaceStore", ->
|
|
|
|
beforeEach ->
|
|
|
|
@constructor = NamespaceStore.constructor
|
|
|
|
|
|
|
|
it "should initialize current() using data saved in config", ->
|
|
|
|
state =
|
|
|
|
"id": "123",
|
|
|
|
"email_address":"bengotow@gmail.com",
|
|
|
|
"object":"namespace"
|
2015-07-16 23:54:20 +08:00
|
|
|
"organization_unit": "label"
|
2015-05-22 09:08:29 +08:00
|
|
|
|
|
|
|
spyOn(atom.config, 'get').andCallFake -> state
|
|
|
|
instance = new @constructor
|
|
|
|
expect(instance.current().id).toEqual(state['id'])
|
|
|
|
expect(instance.current().emailAddress).toEqual(state['email_address'])
|
|
|
|
|
|
|
|
it "should initialize current() to null if data is not present", ->
|
|
|
|
spyOn(atom.config, 'get').andCallFake -> null
|
|
|
|
instance = new @constructor
|
|
|
|
expect(instance.current()).toEqual(null)
|
|
|
|
|
|
|
|
it "should initialize current() to null if data is invalid", ->
|
|
|
|
spyOn(atom.config, 'get').andCallFake -> "this isn't an object"
|
|
|
|
instance = new @constructor
|
2015-07-16 23:54:20 +08:00
|
|
|
expect(instance.current()).toEqual(null)
|