From ce5dfffd1c72bf217de9fae74866c79287a08d80 Mon Sep 17 00:00:00 2001 From: Eric Dobbertin Date: Sun, 4 Dec 2016 19:28:25 -0600 Subject: [PATCH] Remove tests --- .jshintrc | 15 - .travis.yml | 25 - package.js | 23 - tests/collections.js | 88 +--- tests/pubsub.js | 18 - tests/schemas.js | 266 ----------- tests/security.js | 55 --- tests/tests.js | 1060 ------------------------------------------ 8 files changed, 1 insertion(+), 1549 deletions(-) delete mode 100644 .travis.yml delete mode 100644 tests/pubsub.js delete mode 100644 tests/schemas.js delete mode 100644 tests/security.js delete mode 100644 tests/tests.js diff --git a/.jshintrc b/.jshintrc index d89aa16..44837b0 100644 --- a/.jshintrc +++ b/.jshintrc @@ -146,21 +146,6 @@ "SimpleSchema": false, "books": true, "booksSchema": true, - "autoValues": true, - "avSchema": true, - "noSchemaCollection": true, - "Document": true, - "defaultValues": true, - "BlackBox": true, - "defaultValuesSchema": true, - "contextCheck": true, - "contextCheckSchema": true, - "RES": true, - "RESSchema": true, - "booksSubscription": true, - "partOne": true, - "partTwo": true, - "partThree": true, "LocalCollection": false } } diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c7b78bb..0000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -sudo: false - -language: node_js - -node_js: - - 0.10.40 - -cache: - directories: - - $HOME/.meteor - - $HOME/.npm - -before_cache: - - rm -f $HOME/.meteor/log/*.log - -before_install: - # Download Meteor - - PATH=$PATH:$HOME/.meteor - - if [ ! -e $HOME/.meteor/meteor ]; then curl https://install.meteor.com | sh; fi - - # Install spacejam - - npm install -g spacejam - -script: - - spacejam test-packages ./ diff --git a/package.js b/package.js index 42cb44e..fe4ae79 100644 --- a/package.js +++ b/package.js @@ -21,26 +21,3 @@ Package.onUse(function(api) { 'aldeed:schema-deny', ]); }); - -Package.onTest(function(api) { - api.use('aldeed:collection2'); - api.use('aldeed:simple-schema@2.0.0-rc.1'); - api.use('tinytest@1.0.0'); - api.use('test-helpers@1.0.0'); - api.use('underscore@1.0.0'); - api.use('ejson@1.0.0'); - api.use('ordered-dict@1.0.0'); - api.use('random@1.0.0'); - api.use('deps@1.0.0'); - api.use('minimongo@1.0.0'); - - api.addFiles([ - 'tests/schemas.js', - 'tests/collections.js', - 'tests/pubsub.js', - 'tests/security.js', - 'tests/tests.js', - 'tests/tests-deny.js', - 'tests/tests-indexing.js' - ]); -}); diff --git a/tests/collections.js b/tests/collections.js index 0f03468..ebca9df 100644 --- a/tests/collections.js +++ b/tests/collections.js @@ -1,7 +1,6 @@ /* books */ -books = new Mongo.Collection("books"); -books.attachSchema(booksSchema); + // Add one unique index outside of C2 if (Meteor.isServer) { @@ -12,88 +11,3 @@ if (Meteor.isServer) { } books._ensureIndex({field1: 1, field2: 1}, {unique: true, sparse: true}); } - -/* autoValues */ - -autoValues = new Mongo.Collection("autoValues"); -autoValues.attachSchema(avSchema); - -/* noSchemaCollection */ - -noSchemaCollection = new Mongo.Collection('noSchema', { - transform: function(doc) { - doc.userFoo = "userBar"; - return doc; - } -}); - -/* BlackBox */ - -Document = function(data) { - _.extend(this, data); -}; - -Document.prototype = { - constructor: Document, - toString: function() { - return this.toJSONValue.toString(); - }, - clone: function() { - return new Document(this); - }, - equals: function(other) { - if (!(other instanceof Document)) - return false; - return EJSON.stringify(this) === EJSON.stringify(other); - }, - typeName: function() { - return "Document"; - }, - toJSONValue: function() { - return _.extend({}, this); - } -}; - -BlackBox = new Mongo.Collection('black', { - transform: function(doc) { - doc.data = new Document(doc.data); - return doc; - } -}); - -BlackBox.attachSchema(new SimpleSchema({ - name: { - type: String - }, - data: { - type: Document, - blackbox: true - } -}), {transform: true}); - -/* defaultValues */ - -defaultValues = new Mongo.Collection("dv"); -defaultValues.attachSchema(defaultValuesSchema); - -/* contextCheck */ - -contextCheck = new Mongo.Collection("contextCheck"); -contextCheck.attachSchema(contextCheckSchema); - -/* RES */ - -RES = new Mongo.Collection("RES"); -RES.attachSchema(RESSchema); - -/* Products */ - -products = new Mongo.Collection("TestProducts"); -products.attachSchema(Product, { selector: { type: 'simple' } }); -products.attachSchema(ProductVariant, { selector: { type: 'variant' } }); - -/* Extended Products */ -extendedProducts = new Mongo.Collection("ExtendedProducts"); -extendedProducts.attachSchema(Product, {selector: {type: 'simple'}}); -extendedProducts.attachSchema(ProductVariant, {selector: {type: 'variant'}}); -extendedProducts.attachSchema(ExtendedProduct, {selector: {type: 'simple'}}); diff --git a/tests/pubsub.js b/tests/pubsub.js deleted file mode 100644 index 91699f7..0000000 --- a/tests/pubsub.js +++ /dev/null @@ -1,18 +0,0 @@ -function pub(cols) { - _.each(cols, function (col) { - Meteor.publish(null, function () { - return col.find(); - }); - }); -} - -if (Meteor.isServer) { - Meteor.publish("books", function() { - return books.find(); - }); - - pub([autoValues, defaultValues, noSchemaCollection, BlackBox, contextCheck, - RES, products]); -} else { - booksSubscription = Meteor.subscribe("books"); -} \ No newline at end of file diff --git a/tests/schemas.js b/tests/schemas.js deleted file mode 100644 index 0a69895..0000000 --- a/tests/schemas.js +++ /dev/null @@ -1,266 +0,0 @@ -booksSchema = new SimpleSchema({ - title: { - type: String, - label: "Title", - max: 200, - index: 1 - }, - author: { - type: String, - label: "Author" - }, - copies: { - type: SimpleSchema.Integer, - label: "Number of copies", - min: 0 - }, - lastCheckedOut: { - type: Date, - label: "Last date this book was checked out", - optional: true - }, - summary: { - type: String, - label: "Brief summary", - optional: true, - max: 1000 - }, - isbn: { - type: String, - label: "ISBN", - optional: true, - index: 1, - unique: true - }, - field1: { - type: String, - optional: true - }, - field2: { - type: String, - optional: true - }, - createdAt: { - type: Date, - optional: true, - denyUpdate: true - }, - updatedAt: { - type: Date, - optional: true, - denyInsert: true - } -}); - -avSchema = new SimpleSchema({ - name: { - type: String - }, - dateDefault: { - type: Date, - optional: true, - autoValue: function() { - if (!this.isSet) { - return new Date("2013-01-01"); - } - } - }, - dateForce: { - type: Date, - optional: true, - autoValue: function() { - return new Date("2013-01-01"); - } - }, - updateCount: { - type: SimpleSchema.Integer, - autoValue: function() { - if (this.isInsert) { - return 0; - } else { - return {$inc: 1}; - } - } - }, - content: { - type: String, - optional: true - }, - firstWord: { - type: String, - optional: true, - autoValue: function() { - var content = this.field("content"); - if (content.isSet) { - return content.value.split(' ')[0]; - } else { - this.unset(); - } - } - }, - updatesHistory: { - type: Array, - optional: true, - autoValue: function() { - var content = this.field("content"); - if (content.isSet) { - if (this.isInsert) { - return [{ - date: new Date(), - content: content.value - }]; - } else { - return { - $push: { - date: new Date, - content: content.value - } - }; - } - } else { - this.unset(); - } - } - }, - 'updatesHistory.$': { - type: Object, - }, - 'updatesHistory.$.date': { - type: Date, - optional: true - }, - 'updatesHistory.$.content': { - type: String, - optional: true - } -}); - -defaultValuesSchema = new SimpleSchema({ - bool1: { - type: Boolean, - defaultValue: false - } -}); - -contextCheckSchema = new SimpleSchema({ - foo: { - type: String, - optional: true - }, - context: { - type: Object, - optional: true, - }, - 'context.userId': { - type: String, - optional: true, - autoValue: function () { - return this.userId; - } - }, - 'context.isFromTrustedCode': { - type: Boolean, - optional: true, - autoValue: function () { - return this.isFromTrustedCode; - } - }, - 'context.isInsert': { - type: Boolean, - optional: true, - autoValue: function () { - return this.isInsert; - } - }, - 'context.isUpdate': { - type: Boolean, - optional: true, - autoValue: function () { - return this.isUpdate; - } - }, - 'context.docId': { - type: String, - optional: true, - autoValue: function () { - return this.docId; - } - } -}); - -RESSchema = new SimpleSchema({ - foo: { type: String }, - bar: { type: String, optional: true } -}); - -partOne = new SimpleSchema({ - one: { type: String } -}); - -partTwo = new SimpleSchema({ - two: { type: String } -}); - -partThree = new SimpleSchema({ - two: { type: SimpleSchema.Integer } -}); - -Product = new SimpleSchema({ - _id: { - type: String, - optional: true - }, - title: { - type: String, - defaultValue: "" - }, - type: { - label: "Product Type", - type: String, - defaultValue: "simple" - }, - description: { - type: String, - defaultValue: "This is a simple product." - } -}); - -ProductVariant = new SimpleSchema({ - _id: { - type: String, - optional: true - }, - title: { - type: String, - defaultValue: "" - }, - optionTitle: { - label: "Option", - type: String, - optional: true - }, - type: { - label: "Product Variant Type", - type: String, - defaultValue: "variant" - }, - price: { - label: "Price", - type: Number, - min: 0, - optional: true, - defaultValue: 5 - }, - createdAt: { - type: Date, - denyUpdate: true - } -}); - -ExtendedProduct = new SimpleSchema(Product); -ExtendedProduct.extend({ - barcode: { - type: String, - defaultValue: "ABC123" - } -}); diff --git a/tests/security.js b/tests/security.js deleted file mode 100644 index 8e79ab2..0000000 --- a/tests/security.js +++ /dev/null @@ -1,55 +0,0 @@ -if (Meteor.isServer) { - - var allTrue = { - insert: function() { - return true; - }, - update: function() { - return true; - }, - remove: function() { - return true; - } - }; - - defaultValues.allow(allTrue); - books.allow(allTrue); - autoValues.allow(allTrue); - noSchemaCollection.allow(allTrue); - BlackBox.allow(allTrue); - contextCheck.allow(allTrue); - RES.allow(allTrue); - products.allow(allTrue); - - var shouldDeny = false; - books.deny({ - insert: function() { - return shouldDeny; - }, - update: function() { - return shouldDeny; - }, - remove: function() { - return shouldDeny; - } - }); - - // Rig test helper method for setting denyAll - Meteor.methods({ - denyAll: function() { - shouldDeny = true; - }, - allowAll: function() { - shouldDeny = false; - }, - removeAll: function () { - books.remove({}); - autoValues.remove({}); - defaultValues.remove({}); - noSchemaCollection.remove({}); - BlackBox.remove({}); - contextCheck.remove({}); - products.remove({}); - } - }); -} \ No newline at end of file diff --git a/tests/tests.js b/tests/tests.js deleted file mode 100644 index 64ed367..0000000 --- a/tests/tests.js +++ /dev/null @@ -1,1060 +0,0 @@ -Tinytest.addAsync('Collection2 - Reset', function (test, next) { - Meteor.call("removeAll", next); -}); - -var mc = new Mongo.Collection('mc'); -Tinytest.add('Collection2 - Mongo.Collection - simpleSchema', function (test) { - delete mc._c2; - delete mc._collection._c2; - - mc.attachSchema(new SimpleSchema({ - foo: {type: String} - })); - - test.instanceOf(mc.simpleSchema(), SimpleSchema); - - // It should work on the LocalCollection instance, too - if (Meteor.isClient) { - test.instanceOf(mc._collection, LocalCollection); - test.instanceOf(mc._collection.simpleSchema(), SimpleSchema); - } -}); - -Tinytest.add('Collection2 - LocalCollection - simpleSchema', function (test) { - var lc = new Mongo.Collection(null); - - lc.attachSchema(new SimpleSchema({ - foo: {type: String} - })); - - test.instanceOf(lc.simpleSchema(), SimpleSchema); - - // It should work on the LocalCollection instance, too - test.instanceOf(lc._collection, LocalCollection); - test.instanceOf(lc._collection.simpleSchema(), SimpleSchema); -}); - -if (Meteor.isServer) { - // Insert to collection with multiple top-level schemas - Tinytest.add( - 'Collection2 - Multiple Top-Level Schemas - insert selects the correct schema', - function (test) { - var productId = products.insert({ - title: 'Product one' - }, { selector: { type: 'simple' } }); - - var productVariantId = products.insert({ - title: 'Product variant one', - createdAt: new Date() - }, { selector: { type: 'variant' } }); - - var product = products.findOne(productId); - var productVariant = products.findOne(productVariantId); - - // we should receive new docs with correct property set for each type of doc - test.equal(product.description, 'This is a simple product.'); - test.equal(product.price, undefined); - test.equal(productVariant.description, undefined); - test.equal(productVariant.price, 5); - } - ); - - Tinytest.add( - 'Collection2 - Multiple Top-Level Schemas - should insert doc correctly' + - ' with selector passed via doc and via