-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
af5377b
commit 0c7af42
Showing
17 changed files
with
138 additions
and
126 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 was deleted.
Oops, something went wrong.
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
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,76 @@ | ||
var chai = require('chai'); | ||
var should = chai.should(); | ||
var expect = chai.expect; | ||
var nock = require('nock'); | ||
|
||
var cache = require('../lib/cache'); | ||
var slackType = require('../lib/slack/types'); | ||
|
||
|
||
describe('cache', function () { | ||
|
||
it('should be a singleton', function (done) { | ||
var cache1 = require('./../lib/cache'); | ||
var cache2 = require('./../lib/cache'); | ||
expect(cache1).to.equal(cache2); | ||
done(); | ||
}); | ||
|
||
// function get(name, callback) | ||
describe('#search', function () { | ||
|
||
before(function () { | ||
|
||
cache.data.users = [ | ||
{ | ||
"id": "U0BC6D9V1", | ||
"name": "john", | ||
"real_name": "John Doe", | ||
"profile": { | ||
"first_name": "John", | ||
"last_name": "Doe", | ||
"title": "Just a slack user", | ||
"real_name": "John Doe", | ||
"real_name_normalized": "John Doe", | ||
"email": "john@somedomain.com" | ||
} | ||
}]; | ||
}); | ||
|
||
it('it should return a user by e-mail address', function (done) { | ||
cache.data.users = [ | ||
{ | ||
"id": "U0BC6D9V1", | ||
"name": "john", | ||
"real_name": "John Doe", | ||
"profile": { | ||
"first_name": "John", | ||
"last_name": "Doe", | ||
"title": "Just a slack user", | ||
"real_name": "John Doe", | ||
"real_name_normalized": "John Doe", | ||
"email": "john@somedomain.com" | ||
} | ||
}]; | ||
cache.search(slackType.USER, 'john@somedomain.com', function name(err, result) { | ||
expect(result.name).to.equal('john'); | ||
done(); | ||
}); | ||
|
||
}); | ||
|
||
it('it should return a user by name', function (done) { | ||
cache.search(slackType.USER, 'john', function name(err, result) { | ||
expect(result.profile.email).to.equal('john@somedomain.com'); | ||
}); | ||
done(); | ||
}); | ||
|
||
it('it should return a user by user id', function (done) { | ||
cache.search(slackType.USER, 'U0BC6D9V1', function name(err, result) { | ||
expect(result.profile.real_name).to.equal('John Doe'); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); |
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
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
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
Oops, something went wrong.