mirror of
https://github.com/desktop/desktop
synced 2024-10-31 11:59:53 +00:00
Test the users store.
This commit is contained in:
parent
f81a44623d
commit
ab160b7bf9
2 changed files with 42 additions and 1 deletions
|
@ -7,10 +7,18 @@ import * as TestUtils from 'react-addons-test-utils'
|
||||||
|
|
||||||
import App from '../src/app'
|
import App from '../src/app'
|
||||||
import UsersStore from '../src/users-store'
|
import UsersStore from '../src/users-store'
|
||||||
|
import InMemoryStore from './in-memory-store'
|
||||||
|
|
||||||
describe('App', () => {
|
describe('App', () => {
|
||||||
|
let usersStore: UsersStore = null
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
const inMemoryStore = new InMemoryStore()
|
||||||
|
usersStore = new UsersStore(inMemoryStore, inMemoryStore)
|
||||||
|
})
|
||||||
|
|
||||||
it('renders', () => {
|
it('renders', () => {
|
||||||
const app = TestUtils.renderIntoDocument(<App usersStore={new UsersStore()}/>) as React.Component<any, any>
|
const app = TestUtils.renderIntoDocument(<App usersStore={usersStore}/>) as React.Component<any, any>
|
||||||
const node = ReactDOM.findDOMNode(app)
|
const node = ReactDOM.findDOMNode(app)
|
||||||
expect(node).not.to.equal(null)
|
expect(node).not.to.equal(null)
|
||||||
})
|
})
|
||||||
|
|
33
test/users-store-test.ts
Normal file
33
test/users-store-test.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import * as chai from 'chai'
|
||||||
|
const expect = chai.expect
|
||||||
|
|
||||||
|
import User from '../src/user'
|
||||||
|
import UsersStore from '../src/users-store'
|
||||||
|
import InMemoryStore from './in-memory-store'
|
||||||
|
|
||||||
|
describe('UsersStore', () => {
|
||||||
|
let usersStore: UsersStore = null
|
||||||
|
beforeEach(() => {
|
||||||
|
const inMemoryStore = new InMemoryStore()
|
||||||
|
usersStore = new UsersStore(inMemoryStore, inMemoryStore)
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('adding a new user', () => {
|
||||||
|
it('contains the added user', () => {
|
||||||
|
const newUserLogin = 'tonald-drump'
|
||||||
|
usersStore.addUser(new User(newUserLogin, '', ''))
|
||||||
|
|
||||||
|
const users = usersStore.getUsers()
|
||||||
|
expect(users[0].getLogin()).to.equal('newUserLogin')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('notifies when a user is added', () => {
|
||||||
|
let changed = false
|
||||||
|
usersStore.onUsersChanged(() => {
|
||||||
|
changed = true
|
||||||
|
})
|
||||||
|
usersStore.addUser(new User('', '', ''))
|
||||||
|
expect(changed).to.equal(true)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in a new issue