mirror of
https://github.com/wassname/talk.git
synced 2026-06-28 01:16:57 +08:00
86385e0d86
- Introduced the Jest testing framework into our server side code so plugins can now have tests that run
52 lines
1.7 KiB
JavaScript
52 lines
1.7 KiB
JavaScript
const getReactionConfig = require('./getReactionConfig');
|
|
|
|
describe('plugins-api', () => {
|
|
describe('getReactionConfig', () => {
|
|
let config;
|
|
beforeEach(() => {
|
|
config = getReactionConfig('heart');
|
|
});
|
|
|
|
describe('context', () => {
|
|
it('provides a sort function', () => {
|
|
expect(config.context.Sort).toBeInstanceOf(Function);
|
|
const sort = config.context.Sort();
|
|
expect(sort.Comments).toHaveProperty('hearts');
|
|
});
|
|
});
|
|
|
|
describe('hooks', () => {
|
|
it('handles the __resolveType properly', () => {
|
|
expect(config.hooks.ActionSummary.__resolveType).toHaveProperty('post');
|
|
expect(config.hooks.ActionSummary.__resolveType.post).toBeInstanceOf(
|
|
Function
|
|
);
|
|
expect(
|
|
config.hooks.ActionSummary.__resolveType.post({})
|
|
).toBeUndefined();
|
|
expect(
|
|
config.hooks.ActionSummary.__resolveType.post({ action_type: 'LOVE' })
|
|
).toBeUndefined();
|
|
expect(
|
|
config.hooks.ActionSummary.__resolveType.post({
|
|
action_type: 'HEART',
|
|
})
|
|
).toEqual('HeartActionSummary');
|
|
});
|
|
it('handles the __resolveType properly', () => {
|
|
expect(config.hooks.Action.__resolveType).toHaveProperty('post');
|
|
expect(config.hooks.Action.__resolveType.post).toBeInstanceOf(Function);
|
|
expect(config.hooks.Action.__resolveType.post({})).toBeUndefined();
|
|
expect(
|
|
config.hooks.Action.__resolveType.post({ action_type: 'LOVE' })
|
|
).toBeUndefined();
|
|
expect(
|
|
config.hooks.Action.__resolveType.post({
|
|
action_type: 'HEART',
|
|
})
|
|
).toEqual('HeartAction');
|
|
});
|
|
});
|
|
});
|
|
});
|