Skip to content

Commit

Permalink
Patched 0.18 tests (#1566)
Browse files Browse the repository at this point in the history
* updated tests for discount methods

* updated meteor versions

- includes update johanbrook:publication-collector
  • Loading branch information
Aaron Judd authored Nov 11, 2016
1 parent eabddb7 commit a1dbed3
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 45 deletions.
24 changes: 12 additions & 12 deletions .meteor/versions
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
[email protected]
[email protected]
[email protected]
[email protected].14
[email protected].15
[email protected]
[email protected]
alanning:[email protected]
aldeed:[email protected]
aldeed:[email protected]
aldeed:[email protected]
aldeed:[email protected]
aldeed:[email protected].0
aldeed:[email protected].1
aldeed:[email protected]
aldeed:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
babel-runtime@0.1.12
babel-runtime@1.0.0
[email protected]
[email protected]
blaze@2.1.9
blaze@2.2.0
[email protected]
[email protected]
[email protected]
Expand Down Expand Up @@ -53,17 +53,17 @@ cfs:[email protected]
cfs:[email protected]
[email protected]
chuangbo:[email protected]
[email protected].1_2
[email protected].1_3
dburles:[email protected]
[email protected]
[email protected]
[email protected].7
[email protected].8
[email protected]
[email protected].11
[email protected].12
[email protected]
[email protected]
dispatch:[email protected]
ecmascript@0.5.9
ecmascript@0.6.0
[email protected]
[email protected]
[email protected]
Expand All @@ -78,12 +78,12 @@ [email protected]
[email protected]
[email protected]
jeremy:[email protected]
johanbrook:[email protected].3
johanbrook:[email protected].4
jparker:[email protected]
jparker:[email protected]
jparker:[email protected]
[email protected]
juliancwirko:postcss@1.1.1
juliancwirko:postcss@1.2.0
juliancwirko:[email protected]
juliancwirko:[email protected]
kadira:[email protected]
Expand Down Expand Up @@ -112,7 +112,7 @@ [email protected]
[email protected]
[email protected]
[email protected]
momentjs:moment@2.15.2
momentjs:moment@2.16.0
[email protected]
[email protected]
[email protected]
Expand Down Expand Up @@ -140,7 +140,7 @@ [email protected]
[email protected]
[email protected]
[email protected]
risul:[email protected].0_5
risul:[email protected].7
[email protected]
[email protected]
[email protected]
Expand Down
42 changes: 34 additions & 8 deletions imports/plugins/core/discounts/server/methods/methods.app-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import { Meteor } from "meteor/meteor";
import { Roles } from "meteor/alanning:roles";
import { expect } from "meteor/practicalmeteor:chai";
import { sinon } from "meteor/practicalmeteor:sinon";
import { Discounts } from "/imports/plugins/core/discounts/lib/collections";

before(function () {
this.timeout(10000);
Meteor._sleepForMs(7000);
});
const rate = {
discount: 12,
label: "Discount 5",
description: "Discount by 5%",
discountMethod: "rate"
};

describe("discounts methods", function () {
let sandbox;
Expand All @@ -20,10 +23,33 @@ describe("discounts methods", function () {
});

describe("discounts/deleteRate", function () {
it("should throw 403 error with discounts permission", function (done) {
sandbox.stub(Roles, "userIsInRole", () => false);
// this should actually trigger a whole lot of things
expect(() => Meteor.call("discounts/deleteRate", "dummystring")).to.throw(Meteor.Error, /Access Denied/);
// it("should not delete rate without permissions", function (done) {
// const roleStub = sandbox.stub(Roles, "userIsInRole", () => true);
// const discountInsertSpy = sandbox.spy(Discounts, "insert");
// const discountId = Meteor.call("discounts/addRate", rate);
// expect(discountInsertSpy).to.have.been.called;
// Meteor._sleepForMs(500);
//
// sandbox.stub(Roles, "userIsInRole", () => false);
// Meteor.call("discounts/deleteRate", discountId);
// Meteor._sleepForMs(500);
//
// const discountCount = Discounts.find(discountId).count();
// expect(discountCount).to.equal(1);
// return done();
// });

it("should delete rate with discounts permission", function (done) {
sandbox.stub(Roles, "userIsInRole", () => true);
const discountInsertSpy = sandbox.spy(Discounts, "insert");
const discountId = Meteor.call("discounts/addRate", rate);
expect(discountInsertSpy).to.have.been.called;

Meteor.call("discounts/deleteRate", discountId);
Meteor._sleepForMs(500);

const discountCount = Discounts.find(discountId).count();
expect(discountCount).to.equal(0);
return done();
});
});
Expand Down
15 changes: 0 additions & 15 deletions imports/plugins/core/taxes/server/i18n/i18n/en.json

This file was deleted.

7 changes: 0 additions & 7 deletions imports/plugins/core/taxes/server/i18n/i18n/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion imports/plugins/included/discount-codes/register.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Reaction } from "/server/api";

Reaction.registerPackage({
label: "Taxes",
label: "Codes",
name: "discount-codes",
icon: "fa fa-gift",
autoEnable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ import { Meteor } from "meteor/meteor";
import { Roles } from "meteor/alanning:roles";
import { expect } from "meteor/practicalmeteor:chai";
import { sinon } from "meteor/practicalmeteor:sinon";
import { Discounts } from "/imports/plugins/core/discounts/lib/collections";

const code = {
discount: 12,
label: "Discount 5",
description: "Discount by 5%",
discountMethod: "code",
code: "promocode"
};

before(function () {
this.timeout(10000);
Expand All @@ -23,7 +32,19 @@ describe("discount code methods", function () {
it("should throw 403 error with discounts permission", function (done) {
sandbox.stub(Roles, "userIsInRole", () => false);
// this should actually trigger a whole lot of things
expect(() => Meteor.call("discounts/addCode", "dummystring")).to.throw(Meteor.Error, /Access Denied/);
expect(() => Meteor.call("discounts/addCode", code)).to.throw(Meteor.Error, /Access Denied/);
return done();
});
// admin user
it("should add code when user has role", function (done) {
sandbox.stub(Roles, "userIsInRole", () => true);
const discountInsertSpy = sandbox.spy(Discounts, "insert");
const discountId = Meteor.call("discounts/addCode", code);
expect(discountInsertSpy).to.have.been.called;

Meteor._sleepForMs(500);
const discountCount = Discounts.find(discountId).count();
expect(discountCount).to.equal(1);
return done();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Meteor } from "meteor/meteor";
import { Roles } from "meteor/alanning:roles";
import { expect } from "meteor/practicalmeteor:chai";
import { sinon } from "meteor/practicalmeteor:sinon";
import { Discounts } from "/imports/plugins/core/discounts/lib/collections";

before(function () {
this.timeout(10000);
Expand All @@ -19,11 +20,30 @@ describe("discount rate methods", function () {
sandbox.restore();
});

const rate = {
discount: 12,
label: "Discount 5",
description: "Discount by 5%",
discountMethod: "rate"
};

describe("discounts/addRate", function () {
it("should throw 403 error with discounts permission", function (done) {
sandbox.stub(Roles, "userIsInRole", () => false);
// this should actually trigger a whole lot of things
expect(() => Meteor.call("discounts/addRate", "dummystring")).to.throw(Meteor.Error, /Access Denied/);
expect(() => Meteor.call("discounts/addRate", rate)).to.throw(Meteor.Error, /Access Denied/);
return done();
});
// admin user
it("should add rate when user has role", function (done) {
sandbox.stub(Roles, "userIsInRole", () => true);
const discountInsertSpy = sandbox.spy(Discounts, "insert");
const discountId = Meteor.call("discounts/addRate", rate);
expect(discountInsertSpy).to.have.been.called;

const discountCount = Discounts.find(discountId).count();
Meteor._sleepForMs(500);
expect(discountCount).to.equal(1);
return done();
});
});
Expand Down

0 comments on commit a1dbed3

Please sign in to comment.