Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
message test
/* eslint-disable */
import { Meteor } from 'meteor/meteor';
import React from 'react';
import { shallow } from 'enzyme';
import { chai, assert } from 'meteor/practicalmeteor:chai';
import Message from './Message';
describe('Message component', () => {
if (Meteor.isServer) return;
const aTitle = 'a title';
const aSubTitle = 'a subtitle';
it('should render values when title and subtitle are passed to component', () => {
const wrapper = shallow(<Message title={aTitle} subtitle={aSubTitle} />);
assert.isTrue(wrapper.is('.message-wrapper'));
assert.isTrue(wrapper.contains(aTitle));
assert.equal((wrapper.find('.title-message')).length,1);
assert.equal((wrapper.find('.title-message')).text(),aTitle);
assert.isTrue(wrapper.contains(aSubTitle));
assert.equal((wrapper.find('.subtitle-message')).length,1);
assert.equal((wrapper.find('.subtitle-message')).text(),aSubTitle);
});
it('should render values when ONLY title is passed to component', () => {
const wrapper = shallow(<Message title={aTitle} />);
assert.isTrue(wrapper.is('.message-wrapper'));
assert.isTrue(wrapper.contains(aTitle));
assert.equal((wrapper.find('.title-message')).length,1);
assert.equal((wrapper.find('.title-message')).text(),aTitle);
assert.isFalse(wrapper.contains(aSubTitle));
});
it('should render values when ONLY subtitle is passed to component', () => {
const wrapper = shallow(<Message subtitle={aSubTitle} />);
assert.isTrue(wrapper.is('.message-wrapper'));
assert.isFalse(wrapper.contains(aTitle));
assert.isTrue(wrapper.contains(aSubTitle));
assert.equal((wrapper.find('.subtitle-message')).length,1);
assert.equal((wrapper.find('.subtitle-message')).text(),aSubTitle);
});
it('should render NO values when none are passed to component', () => {
const wrapper = shallow(<Message />);
assert.isTrue(wrapper.is('.message-wrapper'));
assert.isFalse(wrapper.contains(aTitle));
assert.isFalse(wrapper.contains(aSubTitle));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment