add mapper and tests

This commit is contained in:
Rashid Khan 2014-02-13 16:54:42 -07:00
parent 7f478ea60e
commit d59079db86
3 changed files with 51 additions and 8 deletions

View file

@ -6,18 +6,29 @@ define(function (require) {
*
* @class Mapper
*/
function Mapper(index, type) {
this.indices = function () {
function Mapper(client) {
/**
* Gets an object containing all fields with their mappings
* @param {dataSource} dataSource
* @param {Number} type
* @return {Object} A hash containing fields and their related mapping
*/
this.getFields = function (dataSource, type) {
return {
foo: {
type: 'string'
},
'foo.bar': {
type: 'long'
}
};
};
this.getFields = function () {
};
this.getFieldType = function (field, type) {
this.getFieldType = function (dataSource, field, type) {
return field, type;
};
}
return Mapper;

View file

@ -1,4 +1,4 @@
// Lint and build CSS
module.exports = function(grunt) {
grunt.registerTask('default', ['jshint:source']);
grunt.registerTask('default', ['jshint:source','test']);
};

32
test/unit/specs/mapper.js Normal file
View file

@ -0,0 +1,32 @@
define(function (require) {
var elasticsearch = require('elasticsearch');
var _ = require('lodash');
var Mapper = require('courier/mapper');
var client = new elasticsearch.Client({
host: 'localhost:9200',
});
describe('Mapper Module', function () {
it('provides a constructor for the Mapper class', function () {
var mapper = new Mapper(client);
expect(mapper).to.be.a(Mapper);
});
it('has a function call getFields that returns an empty object', function () {
var mapper = new Mapper(new Courier());
expect(mapper.getFields()).to.eql({
foo: {
type: 'string'
},
"foo.bar": {
type: 'long'
}
});
});
});
});