This repository has been archived by the owner on May 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marco Segreto
committed
Oct 8, 2015
1 parent
f2c497e
commit a231c2a
Showing
4 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
import AppDispatcher from '../dispatcher'; | ||
import BaseStore from './base_store.js'; | ||
import cfApi from '../util/cf_api.js'; | ||
|
||
class SpaceStore extends BaseStore { | ||
constructor() { | ||
super(); | ||
this._data = []; | ||
} | ||
|
||
get(guid) { | ||
return this._data.find((space) => { | ||
return space.guid === guid; | ||
}); | ||
} | ||
} | ||
|
||
let _SpaceStore = new SpaceStore(); | ||
|
||
export default _SpaceStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
import '../../global_setup.js'; | ||
|
||
import AppDispatcher from '../../../dispatcher.js'; | ||
import SpaceStore from '../../../stores/space_store.js'; | ||
import { spaceActionTypes } from '../../../constants'; | ||
|
||
describe('SpaceStore', () => { | ||
var sandbox; | ||
|
||
beforeEach(() => { | ||
SpaceStore._data = []; | ||
sandbox = sinon.sandbox.create(); | ||
}); | ||
|
||
afterEach(() => { | ||
sandbox.restore(); | ||
}); | ||
|
||
describe('constructor()', () => { | ||
it('should set _data to empty array', () => { | ||
expect(SpaceStore._data).toBeEmptyArray(); | ||
}); | ||
}); | ||
|
||
describe('get()', () => { | ||
it('should return the correct space based on guid', () => { | ||
var testSpaces = [ | ||
{ guid: 'sp1xxa', name: 'testSpaceA', apps: [] }, | ||
{ guid: 'sp1xxb', name: 'testSpaceB', apps: [] } | ||
]; | ||
|
||
SpaceStore._data = testSpaces; | ||
|
||
let actual = SpaceStore.get(testSpaces[0].guid); | ||
|
||
expect(actual).toEqual(testSpaces[0]); | ||
}); | ||
}); | ||
}); |