-
Notifications
You must be signed in to change notification settings - Fork 827
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
Showing
3 changed files
with
46 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Response from './response'; | ||
import objectAssign from 'object-assign'; | ||
|
||
/** | ||
* User state response. Used to update user's state with new values. | ||
* While updating unspecified keys remain untouched. Specified keys are | ||
* updated. | ||
* | ||
* @author Roman Pushkin (roman.pushkin@gmail.com) | ||
* @extends {Response} | ||
* @date 2016-06-16 | ||
* @version 1.1 | ||
* @since 0.1.0 | ||
*/ | ||
export default class UserStateResponse extends Response { | ||
/** | ||
* Constructor. | ||
* | ||
* @type {Object} | ||
* @example | ||
* r = new UserStateResponse({phone: '555-111-22-33'}); | ||
* console.log(r.type); // prints "user-state" | ||
* console.log(r.phone); // prints "555-111-22-33" | ||
*/ | ||
constructor(options) { | ||
const opts = objectAssign({ type: 'user-state' }, options); | ||
super(opts); | ||
objectAssign(this, opts); | ||
} | ||
} |
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,15 @@ | ||
/* eslint-disable no-new */ | ||
import test from 'ava'; | ||
import UserStateResponse from '../../src/responses/user-state-response'; | ||
|
||
test('can be constructed with default parameters', t => { | ||
new UserStateResponse({ foo: 1 }); | ||
t.pass(); | ||
}); | ||
|
||
test('should save properties and have \'user-state\' type', t => { | ||
const r = new UserStateResponse({ foo: 1, bar: 2 }); | ||
t.is(r.foo, 1); | ||
t.is(r.bar, 2); | ||
t.is(r.type, 'user-state'); | ||
}); |