mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 18:11:40 -05:00
53 lines
No EOL
1.7 KiB
JavaScript
53 lines
No EOL
1.7 KiB
JavaScript
// setup JSDOM server side for testing (necessary for Enzyme to mount)
|
|
import 'jsdom-global/register';
|
|
import React from 'react';
|
|
import expect from 'expect';
|
|
import { mount, shallow } from 'enzyme';
|
|
import { Components } from 'meteor/vulcan:core';
|
|
import { initComponentTest } from 'meteor/vulcan:test';
|
|
|
|
|
|
// we must import all the other components, so that "registerComponent" is called
|
|
import '../lib/modules';
|
|
import Datatable from '../lib/modules/components/Datatable'
|
|
// stub collection
|
|
import { createCollection, getDefaultResolvers, getDefaultMutations, registerFragment } from 'meteor/vulcan:core';
|
|
const createDummyCollection = (typeName, schema) => {
|
|
return createCollection({
|
|
collectionName: typeName + 's',
|
|
typeName,
|
|
schema,
|
|
resolvers: getDefaultResolvers(typeName + 's'),
|
|
mutations: getDefaultMutations(typeName + 's')
|
|
});
|
|
}
|
|
const Articles = createDummyCollection('Article', {
|
|
name: {
|
|
type: String
|
|
}
|
|
})
|
|
registerFragment(`
|
|
fragment ArticlesDefaultFragment on Article {
|
|
name
|
|
}
|
|
`);
|
|
|
|
// setup Vulcan (load components, initialize fragments)
|
|
initComponentTest()
|
|
|
|
|
|
describe('vulcan-core/components', function () {
|
|
describe('DataTable', function () {
|
|
it('shallow renders DataTable', function () {
|
|
const wrapper = shallow(<Datatable
|
|
collection={Articles} />)
|
|
expect(wrapper).toBeDefined()
|
|
})
|
|
it('render a static version', function () {
|
|
const wrapper = shallow(<Datatable
|
|
data={[{ name: 'foo' }, { name: 'bar' }]} />)
|
|
const content = wrapper.find('DatatableContents').first()
|
|
expect(content).toBeDefined()
|
|
})
|
|
})
|
|
}) |