mongoose-plugin-tags
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -0,1 +1,4 @@ | ||
'use strict'; | ||
/* jshint node: true */ | ||
var fs = require('fs'); | ||
@@ -2,0 +5,0 @@ var args = require('yargs').argv; |
{ | ||
"name": "mongoose-plugin-tags", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Mongoose.js plugin to automatically generate tags from a document field.", | ||
@@ -5,0 +5,0 @@ "main": "tags.js", |
@@ -12,2 +12,6 @@ mongoose-plugin-tags | ||
## Installation | ||
`npm i --save mongoose-plugin-tags` | ||
## API Reference | ||
@@ -14,0 +18,0 @@ **Example** |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/* jshint node: true */ | ||
@@ -2,0 +3,0 @@ |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
/* jshint node: true, jasmine: true */ | ||
@@ -6,2 +7,3 @@ | ||
var Schema = mongoose.Schema; | ||
var connection; | ||
@@ -11,3 +13,3 @@ // Mongoose uses internal caching for models. | ||
// use the internal model cache for the reference. | ||
// This removes the mongoose entirely from node's cache | ||
// This removes mongoose entirely from node's cache | ||
delete require.cache.mongoose; | ||
@@ -41,3 +43,3 @@ | ||
beforeEach(function () { | ||
schema = BlogSchema(); | ||
schema = blogSchema(); | ||
}); | ||
@@ -80,3 +82,3 @@ | ||
it('should compile the model with the tag plugin', function () { | ||
var schema = BlogSchema(); | ||
var schema = blogSchema(); | ||
schema.path('blog').options.tags = true; | ||
@@ -90,7 +92,9 @@ schema.plugin(tags); | ||
it('should set `tags` to an empty array', function () { | ||
expect(Blog().tags.toObject()).toEqual([]); | ||
var blog = new Blog(); | ||
expect(blog.tags.toObject()).toEqual([]); | ||
}); | ||
it('should set `tags` to an empty array on initial save with no tags', function (done) { | ||
Blog().save(function (err, blog) { | ||
var blog = new Blog(); | ||
blog.save(function (err, blog) { | ||
expect(blog.tags.toObject()).toEqual([]); | ||
@@ -102,7 +106,9 @@ done(); | ||
it('should set `tags` to an empty array', function () { | ||
expect(Blog(blogData).tags.toObject()).toEqual([]); | ||
var blog = new Blog(blogData); | ||
expect(blog.tags.toObject()).toEqual([]); | ||
}); | ||
it('should set `tags` to a unique array on initial save with tags', function (done) { | ||
Blog(blogData).save(function (err, blog) { | ||
var blog = new Blog(blogData); | ||
blog.save(function (err, blog) { | ||
expect(blog.tags.toObject()).toEqual(expectedTags); | ||
@@ -114,3 +120,4 @@ done(); | ||
it('should update `tags` on subsequent saves', function (done) { | ||
Blog(blogData).save(function (err, blog) { | ||
var blog = new Blog(blogData); | ||
blog.save(function (err, blog) { | ||
blog.blog = 'This is my sweet update! #foo #AhhhhYeah'; | ||
@@ -133,3 +140,3 @@ | ||
beforeAll(function () { | ||
var schema = BlogSchema(); | ||
var schema = blogSchema(); | ||
schema.path('title').options.tags = true; | ||
@@ -143,7 +150,9 @@ schema.path('blog').options.tags = true; | ||
it('should set `tags` to an empty array', function () { | ||
expect(Blog().tags.toObject()).toEqual([]); | ||
var blog = new Blog(); | ||
expect(blog.tags.toObject()).toEqual([]); | ||
}); | ||
it('should set `tags` to an empty array on initial save with no tags', function (done) { | ||
Blog().save(function (err, blog) { | ||
var blog = new Blog(); | ||
blog.save(function (err, blog) { | ||
expect(blog.tags.toObject()).toEqual([]); | ||
@@ -155,7 +164,9 @@ done(); | ||
it('should set `tags` to an empty array', function () { | ||
expect(Blog(blogData).tags.toObject()).toEqual([]); | ||
var blog = new Blog(blogData); | ||
expect(blog.tags.toObject()).toEqual([]); | ||
}); | ||
it('should set `tags` to a unique array on initial save with tags', function (done) { | ||
Blog(blogData).save(function (err, blog) { | ||
var blog = new Blog(blogData); | ||
blog.save(function (err, blog) { | ||
expect(blog.tags.toObject()).toEqual(['super', 'blog', 'woohoo']); | ||
@@ -167,3 +178,4 @@ done(); | ||
it('should update `tags` on subsequent saves', function (done) { | ||
Blog(blogData).save(function (err, blog) { | ||
var blog = new Blog(blogData); | ||
blog.save(function (err, blog) { | ||
blog.blog = 'This is my sweet update! #foo #AhhhhYeah'; | ||
@@ -194,4 +206,4 @@ | ||
function BlogSchema() { | ||
return Schema({ | ||
function blogSchema() { | ||
return new Schema({ | ||
title: String, | ||
@@ -198,0 +210,0 @@ blog: String, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29361
333
82