Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Sample vows test for Opportunity Type #234

Closed
wants to merge 1 commit into from

3 participants

@vinaysingu

No description provided.

@mikerodonnell89

This looks good, but for these really basic model tests, we have a one-and-done function that we can use, making it much easier to pump these tests out. Check out the Honorific test

@shackbarth

Vinay, if you're not doing anything fancy with verification of custom business logic, then it's easier just to use the one-liner version of the crud tests, which you can see here:

https://github.com/xtuple/xtuple/blob/master/node-datasource/test/vows/models/honorific.js

Being able to do the whole thing longhand is good practice and will be important for the heavier business objects, but I'd recommend you use the easy solution for these easy objects. It will speed up your work and result in less needlessly copied code.

@shackbarth shackbarth closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 4, 2013
  1. vows test for OpportunityType

    vinay authored
This page is out of date. Refresh to see the latest.
Showing with 68 additions and 0 deletions.
  1. +68 −0 node-datasource/test/vows/wip/OpportunityType.js
View
68 node-datasource/test/vows/wip/OpportunityType.js
@@ -0,0 +1,68 @@
+(function () {
+ "use strict";
+ var vows = require("vows"),
+ assert = require("assert"),
+ _ = require("underscore"),
+ zombieAuth = require("../lib/zombie_auth.js"),
+ crud = require("../lib/crud.js");
+ var data = {
+ createHash : {
+ name : 'Test Name',
+ description : 'Test Description'
+ },
+ updateHash : {
+ description : 'Updated Description'
+ }
+ };
+ vows.describe('XM.OpportunityType CRUD Test').addBatch({
+ 'INITIAliZE' : {
+ topic: function () {
+ var that = this,
+ callback = function () {
+ data.model = new XM.OpportunityType();
+ that.callback(null, data);
+ };
+ zombieAuth.loadApp(callback);
+ },
+ 'The record type is OpportunityType': function(data) {
+ assert.equal(data.model.recordType, "XM.OpportunityType");
+ }
+ }
+ }).addBatch({
+ 'Create' : crud.create(data, {
+ 'set values' : {
+ topic : function(){
+ data.model.set(data.createHash);
+ return data;
+ },
+ 'Verify the Last Error is null': function (data) {
+ assert.isNull(data.model.lastError);
+ },
+ 'save->' : crud.save(data)
+ }
+ })
+ }).addBatch({
+ 'CHECKS PARAMETERS' : {
+ topic : function () {
+ return data;
+ },
+ 'required attributes' : {
+ 'name is required' : function () {
+ assert.isTrue(_.contains(data.model.requiredAttributes, "name"));
+ }
+ }
+ }
+ }).addBatch({
+ 'We can UPDATE the Opportunity Type': crud.update(data, {
+ '-> Set values': {
+ topic: function () {
+ data.model.set(data.updateHash);
+ return data;
+ },
+ '-> Commit Opportunity Type': crud.save(data)
+ }
+ })
+ }).addBatch({
+ 'Delete' : crud.destroy(data)
+ }).export(module);
+}());
Something went wrong with that request. Please try again.