How to use not method in Cypress

Best JavaScript code snippet using cypress

assert.js

Source:assert.js Github

copy

Full Screen

1/*!2 * chai3 * Copyright(c) 2011-2013 Jake Luer <jake@alogicalparadox.com>4 * MIT Licensed5 */6module.exports = function (chai, util) {7  /*!8   * Chai dependencies.9   */10  var Assertion = chai.Assertion11    , flag = util.flag;12  /*!13   * Module export.14   */15  /**16   * ### assert(expression, message)17   *18   * Write your own test expressions.19   *20   *     assert('foo' !== 'bar', 'foo is not bar');21   *     assert(Array.isArray([]), 'empty arrays are arrays');22   *23   * @param {Mixed} expression to test for truthiness24   * @param {String} message to display on error25   * @name assert26   * @api public27   */28  var assert = chai.assert = function (express, errmsg) {29    var test = new Assertion(null);30    test.assert(31        express32      , errmsg33      , '[ negation message unavailable ]'34    );35  };36  /**37   * ### .fail(actual, expected, [message], [operator])38   *39   * Throw a failure. Node.js `assert` module-compatible.40   *41   * @name fail42   * @param {Mixed} actual43   * @param {Mixed} expected44   * @param {String} message45   * @param {String} operator46   * @api public47   */48  assert.fail = function (actual, expected, message, operator) {49    throw new chai.AssertionError({50        actual: actual51      , expected: expected52      , message: message53      , operator: operator54      , stackStartFunction: assert.fail55    });56  };57  /**58   * ### .ok(object, [message])59   *60   * Asserts that `object` is truthy.61   *62   *     assert.ok('everything', 'everything is ok');63   *     assert.ok(false, 'this will fail');64   *65   * @name ok66   * @param {Mixed} object to test67   * @param {String} message68   * @api public69   */70  assert.ok = function (val, msg) {71    new Assertion(val, msg).is.ok;72  };73  /**74   * ### .equal(actual, expected, [message])75   *76   * Asserts non-strict equality (`==`) of `actual` and `expected`.77   *78   *     assert.equal(3, '3', '== coerces values to strings');79   *80   * @name equal81   * @param {Mixed} actual82   * @param {Mixed} expected83   * @param {String} message84   * @api public85   */86  assert.equal = function (act, exp, msg) {87    var test = new Assertion(act, msg);88    test.assert(89        exp == flag(test, 'object')90      , 'expected #{this} to equal #{exp}'91      , 'expected #{this} to not equal #{act}'92      , exp93      , act94    );95  };96  /**97   * ### .notEqual(actual, expected, [message])98   *99   * Asserts non-strict inequality (`!=`) of `actual` and `expected`.100   *101   *     assert.notEqual(3, 4, 'these numbers are not equal');102   *103   * @name notEqual104   * @param {Mixed} actual105   * @param {Mixed} expected106   * @param {String} message107   * @api public108   */109  assert.notEqual = function (act, exp, msg) {110    var test = new Assertion(act, msg);111    test.assert(112        exp != flag(test, 'object')113      , 'expected #{this} to not equal #{exp}'114      , 'expected #{this} to equal #{act}'115      , exp116      , act117    );118  };119  /**120   * ### .strictEqual(actual, expected, [message])121   *122   * Asserts strict equality (`===`) of `actual` and `expected`.123   *124   *     assert.strictEqual(true, true, 'these booleans are strictly equal');125   *126   * @name strictEqual127   * @param {Mixed} actual128   * @param {Mixed} expected129   * @param {String} message130   * @api public131   */132  assert.strictEqual = function (act, exp, msg) {133    new Assertion(act, msg).to.equal(exp);134  };135  /**136   * ### .notStrictEqual(actual, expected, [message])137   *138   * Asserts strict inequality (`!==`) of `actual` and `expected`.139   *140   *     assert.notStrictEqual(3, '3', 'no coercion for strict equality');141   *142   * @name notStrictEqual143   * @param {Mixed} actual144   * @param {Mixed} expected145   * @param {String} message146   * @api public147   */148  assert.notStrictEqual = function (act, exp, msg) {149    new Assertion(act, msg).to.not.equal(exp);150  };151  /**152   * ### .deepEqual(actual, expected, [message])153   *154   * Asserts that `actual` is deeply equal to `expected`.155   *156   *     assert.deepEqual({ tea: 'green' }, { tea: 'green' });157   *158   * @name deepEqual159   * @param {Mixed} actual160   * @param {Mixed} expected161   * @param {String} message162   * @api public163   */164  assert.deepEqual = function (act, exp, msg) {165    new Assertion(act, msg).to.eql(exp);166  };167  /**168   * ### .notDeepEqual(actual, expected, [message])169   *170   * Assert that `actual` is not deeply equal to `expected`.171   *172   *     assert.notDeepEqual({ tea: 'green' }, { tea: 'jasmine' });173   *174   * @name notDeepEqual175   * @param {Mixed} actual176   * @param {Mixed} expected177   * @param {String} message178   * @api public179   */180  assert.notDeepEqual = function (act, exp, msg) {181    new Assertion(act, msg).to.not.eql(exp);182  };183  /**184   * ### .isTrue(value, [message])185   *186   * Asserts that `value` is true.187   *188   *     var teaServed = true;189   *     assert.isTrue(teaServed, 'the tea has been served');190   *191   * @name isTrue192   * @param {Mixed} value193   * @param {String} message194   * @api public195   */196  assert.isTrue = function (val, msg) {197    new Assertion(val, msg).is['true'];198  };199  /**200   * ### .isFalse(value, [message])201   *202   * Asserts that `value` is false.203   *204   *     var teaServed = false;205   *     assert.isFalse(teaServed, 'no tea yet? hmm...');206   *207   * @name isFalse208   * @param {Mixed} value209   * @param {String} message210   * @api public211   */212  assert.isFalse = function (val, msg) {213    new Assertion(val, msg).is['false'];214  };215  /**216   * ### .isNull(value, [message])217   *218   * Asserts that `value` is null.219   *220   *     assert.isNull(err, 'there was no error');221   *222   * @name isNull223   * @param {Mixed} value224   * @param {String} message225   * @api public226   */227  assert.isNull = function (val, msg) {228    new Assertion(val, msg).to.equal(null);229  };230  /**231   * ### .isNotNull(value, [message])232   *233   * Asserts that `value` is not null.234   *235   *     var tea = 'tasty chai';236   *     assert.isNotNull(tea, 'great, time for tea!');237   *238   * @name isNotNull239   * @param {Mixed} value240   * @param {String} message241   * @api public242   */243  assert.isNotNull = function (val, msg) {244    new Assertion(val, msg).to.not.equal(null);245  };246  /**247   * ### .isUndefined(value, [message])248   *249   * Asserts that `value` is `undefined`.250   *251   *     var tea;252   *     assert.isUndefined(tea, 'no tea defined');253   *254   * @name isUndefined255   * @param {Mixed} value256   * @param {String} message257   * @api public258   */259  assert.isUndefined = function (val, msg) {260    new Assertion(val, msg).to.equal(undefined);261  };262  /**263   * ### .isDefined(value, [message])264   *265   * Asserts that `value` is not `undefined`.266   *267   *     var tea = 'cup of chai';268   *     assert.isDefined(tea, 'tea has been defined');269   *270   * @name isUndefined271   * @param {Mixed} value272   * @param {String} message273   * @api public274   */275  assert.isDefined = function (val, msg) {276    new Assertion(val, msg).to.not.equal(undefined);277  };278  /**279   * ### .isFunction(value, [message])280   *281   * Asserts that `value` is a function.282   *283   *     function serveTea() { return 'cup of tea'; };284   *     assert.isFunction(serveTea, 'great, we can have tea now');285   *286   * @name isFunction287   * @param {Mixed} value288   * @param {String} message289   * @api public290   */291  assert.isFunction = function (val, msg) {292    new Assertion(val, msg).to.be.a('function');293  };294  /**295   * ### .isNotFunction(value, [message])296   *297   * Asserts that `value` is _not_ a function.298   *299   *     var serveTea = [ 'heat', 'pour', 'sip' ];300   *     assert.isNotFunction(serveTea, 'great, we have listed the steps');301   *302   * @name isNotFunction303   * @param {Mixed} value304   * @param {String} message305   * @api public306   */307  assert.isNotFunction = function (val, msg) {308    new Assertion(val, msg).to.not.be.a('function');309  };310  /**311   * ### .isObject(value, [message])312   *313   * Asserts that `value` is an object (as revealed by314   * `Object.prototype.toString`).315   *316   *     var selection = { name: 'Chai', serve: 'with spices' };317   *     assert.isObject(selection, 'tea selection is an object');318   *319   * @name isObject320   * @param {Mixed} value321   * @param {String} message322   * @api public323   */324  assert.isObject = function (val, msg) {325    new Assertion(val, msg).to.be.a('object');326  };327  /**328   * ### .isNotObject(value, [message])329   *330   * Asserts that `value` is _not_ an object.331   *332   *     var selection = 'chai'333   *     assert.isObject(selection, 'tea selection is not an object');334   *     assert.isObject(null, 'null is not an object');335   *336   * @name isNotObject337   * @param {Mixed} value338   * @param {String} message339   * @api public340   */341  assert.isNotObject = function (val, msg) {342    new Assertion(val, msg).to.not.be.a('object');343  };344  /**345   * ### .isArray(value, [message])346   *347   * Asserts that `value` is an array.348   *349   *     var menu = [ 'green', 'chai', 'oolong' ];350   *     assert.isArray(menu, 'what kind of tea do we want?');351   *352   * @name isArray353   * @param {Mixed} value354   * @param {String} message355   * @api public356   */357  assert.isArray = function (val, msg) {358    new Assertion(val, msg).to.be.an('array');359  };360  /**361   * ### .isNotArray(value, [message])362   *363   * Asserts that `value` is _not_ an array.364   *365   *     var menu = 'green|chai|oolong';366   *     assert.isNotArray(menu, 'what kind of tea do we want?');367   *368   * @name isNotArray369   * @param {Mixed} value370   * @param {String} message371   * @api public372   */373  assert.isNotArray = function (val, msg) {374    new Assertion(val, msg).to.not.be.an('array');375  };376  /**377   * ### .isString(value, [message])378   *379   * Asserts that `value` is a string.380   *381   *     var teaOrder = 'chai';382   *     assert.isString(teaOrder, 'order placed');383   *384   * @name isString385   * @param {Mixed} value386   * @param {String} message387   * @api public388   */389  assert.isString = function (val, msg) {390    new Assertion(val, msg).to.be.a('string');391  };392  /**393   * ### .isNotString(value, [message])394   *395   * Asserts that `value` is _not_ a string.396   *397   *     var teaOrder = 4;398   *     assert.isNotString(teaOrder, 'order placed');399   *400   * @name isNotString401   * @param {Mixed} value402   * @param {String} message403   * @api public404   */405  assert.isNotString = function (val, msg) {406    new Assertion(val, msg).to.not.be.a('string');407  };408  /**409   * ### .isNumber(value, [message])410   *411   * Asserts that `value` is a number.412   *413   *     var cups = 2;414   *     assert.isNumber(cups, 'how many cups');415   *416   * @name isNumber417   * @param {Number} value418   * @param {String} message419   * @api public420   */421  assert.isNumber = function (val, msg) {422    new Assertion(val, msg).to.be.a('number');423  };424  /**425   * ### .isNotNumber(value, [message])426   *427   * Asserts that `value` is _not_ a number.428   *429   *     var cups = '2 cups please';430   *     assert.isNotNumber(cups, 'how many cups');431   *432   * @name isNotNumber433   * @param {Mixed} value434   * @param {String} message435   * @api public436   */437  assert.isNotNumber = function (val, msg) {438    new Assertion(val, msg).to.not.be.a('number');439  };440  /**441   * ### .isBoolean(value, [message])442   *443   * Asserts that `value` is a boolean.444   *445   *     var teaReady = true446   *       , teaServed = false;447   *448   *     assert.isBoolean(teaReady, 'is the tea ready');449   *     assert.isBoolean(teaServed, 'has tea been served');450   *451   * @name isBoolean452   * @param {Mixed} value453   * @param {String} message454   * @api public455   */456  assert.isBoolean = function (val, msg) {457    new Assertion(val, msg).to.be.a('boolean');458  };459  /**460   * ### .isNotBoolean(value, [message])461   *462   * Asserts that `value` is _not_ a boolean.463   *464   *     var teaReady = 'yep'465   *       , teaServed = 'nope';466   *467   *     assert.isNotBoolean(teaReady, 'is the tea ready');468   *     assert.isNotBoolean(teaServed, 'has tea been served');469   *470   * @name isNotBoolean471   * @param {Mixed} value472   * @param {String} message473   * @api public474   */475  assert.isNotBoolean = function (val, msg) {476    new Assertion(val, msg).to.not.be.a('boolean');477  };478  /**479   * ### .typeOf(value, name, [message])480   *481   * Asserts that `value`'s type is `name`, as determined by482   * `Object.prototype.toString`.483   *484   *     assert.typeOf({ tea: 'chai' }, 'object', 'we have an object');485   *     assert.typeOf(['chai', 'jasmine'], 'array', 'we have an array');486   *     assert.typeOf('tea', 'string', 'we have a string');487   *     assert.typeOf(/tea/, 'regexp', 'we have a regular expression');488   *     assert.typeOf(null, 'null', 'we have a null');489   *     assert.typeOf(undefined, 'undefined', 'we have an undefined');490   *491   * @name typeOf492   * @param {Mixed} value493   * @param {String} name494   * @param {String} message495   * @api public496   */497  assert.typeOf = function (val, type, msg) {498    new Assertion(val, msg).to.be.a(type);499  };500  /**501   * ### .notTypeOf(value, name, [message])502   *503   * Asserts that `value`'s type is _not_ `name`, as determined by504   * `Object.prototype.toString`.505   *506   *     assert.notTypeOf('tea', 'number', 'strings are not numbers');507   *508   * @name notTypeOf509   * @param {Mixed} value510   * @param {String} typeof name511   * @param {String} message512   * @api public513   */514  assert.notTypeOf = function (val, type, msg) {515    new Assertion(val, msg).to.not.be.a(type);516  };517  /**518   * ### .instanceOf(object, constructor, [message])519   *520   * Asserts that `value` is an instance of `constructor`.521   *522   *     var Tea = function (name) { this.name = name; }523   *       , chai = new Tea('chai');524   *525   *     assert.instanceOf(chai, Tea, 'chai is an instance of tea');526   *527   * @name instanceOf528   * @param {Object} object529   * @param {Constructor} constructor530   * @param {String} message531   * @api public532   */533  assert.instanceOf = function (val, type, msg) {534    new Assertion(val, msg).to.be.instanceOf(type);535  };536  /**537   * ### .notInstanceOf(object, constructor, [message])538   *539   * Asserts `value` is not an instance of `constructor`.540   *541   *     var Tea = function (name) { this.name = name; }542   *       , chai = new String('chai');543   *544   *     assert.notInstanceOf(chai, Tea, 'chai is not an instance of tea');545   *546   * @name notInstanceOf547   * @param {Object} object548   * @param {Constructor} constructor549   * @param {String} message550   * @api public551   */552  assert.notInstanceOf = function (val, type, msg) {553    new Assertion(val, msg).to.not.be.instanceOf(type);554  };555  /**556   * ### .include(haystack, needle, [message])557   *558   * Asserts that `haystack` includes `needle`. Works559   * for strings and arrays.560   *561   *     assert.include('foobar', 'bar', 'foobar contains string "bar"');562   *     assert.include([ 1, 2, 3 ], 3, 'array contains value');563   *564   * @name include565   * @param {Array|String} haystack566   * @param {Mixed} needle567   * @param {String} message568   * @api public569   */570  assert.include = function (exp, inc, msg) {571    var obj = new Assertion(exp, msg);572    if (Array.isArray(exp)) {573      obj.to.include(inc);574    } else if ('string' === typeof exp) {575      obj.to.contain.string(inc);576    }577  };578  /**579   * ### .match(value, regexp, [message])580   *581   * Asserts that `value` matches the regular expression `regexp`.582   *583   *     assert.match('foobar', /^foo/, 'regexp matches');584   *585   * @name match586   * @param {Mixed} value587   * @param {RegExp} regexp588   * @param {String} message589   * @api public590   */591  assert.match = function (exp, re, msg) {592    new Assertion(exp, msg).to.match(re);593  };594  /**595   * ### .notMatch(value, regexp, [message])596   *597   * Asserts that `value` does not match the regular expression `regexp`.598   *599   *     assert.notMatch('foobar', /^foo/, 'regexp does not match');600   *601   * @name notMatch602   * @param {Mixed} value603   * @param {RegExp} regexp604   * @param {String} message605   * @api public606   */607  assert.notMatch = function (exp, re, msg) {608    new Assertion(exp, msg).to.not.match(re);609  };610  /**611   * ### .property(object, property, [message])612   *613   * Asserts that `object` has a property named by `property`.614   *615   *     assert.property({ tea: { green: 'matcha' }}, 'tea');616   *617   * @name property618   * @param {Object} object619   * @param {String} property620   * @param {String} message621   * @api public622   */623  assert.property = function (obj, prop, msg) {624    new Assertion(obj, msg).to.have.property(prop);625  };626  /**627   * ### .notProperty(object, property, [message])628   *629   * Asserts that `object` does _not_ have a property named by `property`.630   *631   *     assert.notProperty({ tea: { green: 'matcha' }}, 'coffee');632   *633   * @name notProperty634   * @param {Object} object635   * @param {String} property636   * @param {String} message637   * @api public638   */639  assert.notProperty = function (obj, prop, msg) {640    new Assertion(obj, msg).to.not.have.property(prop);641  };642  /**643   * ### .deepProperty(object, property, [message])644   *645   * Asserts that `object` has a property named by `property`, which can be a646   * string using dot- and bracket-notation for deep reference.647   *648   *     assert.deepProperty({ tea: { green: 'matcha' }}, 'tea.green');649   *650   * @name deepProperty651   * @param {Object} object652   * @param {String} property653   * @param {String} message654   * @api public655   */656  assert.deepProperty = function (obj, prop, msg) {657    new Assertion(obj, msg).to.have.deep.property(prop);658  };659  /**660   * ### .notDeepProperty(object, property, [message])661   *662   * Asserts that `object` does _not_ have a property named by `property`, which663   * can be a string using dot- and bracket-notation for deep reference.664   *665   *     assert.notDeepProperty({ tea: { green: 'matcha' }}, 'tea.oolong');666   *667   * @name notDeepProperty668   * @param {Object} object669   * @param {String} property670   * @param {String} message671   * @api public672   */673  assert.notDeepProperty = function (obj, prop, msg) {674    new Assertion(obj, msg).to.not.have.deep.property(prop);675  };676  /**677   * ### .propertyVal(object, property, value, [message])678   *679   * Asserts that `object` has a property named by `property` with value given680   * by `value`.681   *682   *     assert.propertyVal({ tea: 'is good' }, 'tea', 'is good');683   *684   * @name propertyVal685   * @param {Object} object686   * @param {String} property687   * @param {Mixed} value688   * @param {String} message689   * @api public690   */691  assert.propertyVal = function (obj, prop, val, msg) {692    new Assertion(obj, msg).to.have.property(prop, val);693  };694  /**695   * ### .propertyNotVal(object, property, value, [message])696   *697   * Asserts that `object` has a property named by `property`, but with a value698   * different from that given by `value`.699   *700   *     assert.propertyNotVal({ tea: 'is good' }, 'tea', 'is bad');701   *702   * @name propertyNotVal703   * @param {Object} object704   * @param {String} property705   * @param {Mixed} value706   * @param {String} message707   * @api public708   */709  assert.propertyNotVal = function (obj, prop, val, msg) {710    new Assertion(obj, msg).to.not.have.property(prop, val);711  };712  /**713   * ### .deepPropertyVal(object, property, value, [message])714   *715   * Asserts that `object` has a property named by `property` with value given716   * by `value`. `property` can use dot- and bracket-notation for deep717   * reference.718   *719   *     assert.deepPropertyVal({ tea: { green: 'matcha' }}, 'tea.green', 'matcha');720   *721   * @name deepPropertyVal722   * @param {Object} object723   * @param {String} property724   * @param {Mixed} value725   * @param {String} message726   * @api public727   */728  assert.deepPropertyVal = function (obj, prop, val, msg) {729    new Assertion(obj, msg).to.have.deep.property(prop, val);730  };731  /**732   * ### .deepPropertyNotVal(object, property, value, [message])733   *734   * Asserts that `object` has a property named by `property`, but with a value735   * different from that given by `value`. `property` can use dot- and736   * bracket-notation for deep reference.737   *738   *     assert.deepPropertyNotVal({ tea: { green: 'matcha' }}, 'tea.green', 'konacha');739   *740   * @name deepPropertyNotVal741   * @param {Object} object742   * @param {String} property743   * @param {Mixed} value744   * @param {String} message745   * @api public746   */747  assert.deepPropertyNotVal = function (obj, prop, val, msg) {748    new Assertion(obj, msg).to.not.have.deep.property(prop, val);749  };750  /**751   * ### .lengthOf(object, length, [message])752   *753   * Asserts that `object` has a `length` property with the expected value.754   *755   *     assert.lengthOf([1,2,3], 3, 'array has length of 3');756   *     assert.lengthOf('foobar', 5, 'string has length of 6');757   *758   * @name lengthOf759   * @param {Mixed} object760   * @param {Number} length761   * @param {String} message762   * @api public763   */764  assert.lengthOf = function (exp, len, msg) {765    new Assertion(exp, msg).to.have.length(len);766  };767  /**768   * ### .throws(function, [constructor/string/regexp], [string/regexp], [message])769   *770   * Asserts that `function` will throw an error that is an instance of771   * `constructor`, or alternately that it will throw an error with message772   * matching `regexp`.773   *774   *     assert.throw(fn, 'function throws a reference error');775   *     assert.throw(fn, /function throws a reference error/);776   *     assert.throw(fn, ReferenceError);777   *     assert.throw(fn, ReferenceError, 'function throws a reference error');778   *     assert.throw(fn, ReferenceError, /function throws a reference error/);779   *780   * @name throws781   * @alias throw782   * @alias Throw783   * @param {Function} function784   * @param {ErrorConstructor} constructor785   * @param {RegExp} regexp786   * @param {String} message787   * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types788   * @api public789   */790  assert.Throw = function (fn, errt, errs, msg) {791    if ('string' === typeof errt || errt instanceof RegExp) {792      errs = errt;793      errt = null;794    }795    new Assertion(fn, msg).to.Throw(errt, errs);796  };797  /**798   * ### .doesNotThrow(function, [constructor/regexp], [message])799   *800   * Asserts that `function` will _not_ throw an error that is an instance of801   * `constructor`, or alternately that it will not throw an error with message802   * matching `regexp`.803   *804   *     assert.doesNotThrow(fn, Error, 'function does not throw');805   *806   * @name doesNotThrow807   * @param {Function} function808   * @param {ErrorConstructor} constructor809   * @param {RegExp} regexp810   * @param {String} message811   * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types812   * @api public813   */814  assert.doesNotThrow = function (fn, type, msg) {815    if ('string' === typeof type) {816      msg = type;817      type = null;818    }819    new Assertion(fn, msg).to.not.Throw(type);820  };821  /**822   * ### .operator(val1, operator, val2, [message])823   *824   * Compares two values using `operator`.825   *826   *     assert.operator(1, '<', 2, 'everything is ok');827   *     assert.operator(1, '>', 2, 'this will fail');828   *829   * @name operator830   * @param {Mixed} val1831   * @param {String} operator832   * @param {Mixed} val2833   * @param {String} message834   * @api public835   */836  assert.operator = function (val, operator, val2, msg) {837    if (!~['==', '===', '>', '>=', '<', '<=', '!=', '!=='].indexOf(operator)) {838      throw new Error('Invalid operator "' + operator + '"');839    }840    var test = new Assertion(eval(val + operator + val2), msg);841    test.assert(842        true === flag(test, 'object')843      , 'expected ' + util.inspect(val) + ' to be ' + operator + ' ' + util.inspect(val2)844      , 'expected ' + util.inspect(val) + ' to not be ' + operator + ' ' + util.inspect(val2) );845  };846  /**847   * ### .closeTo(actual, expected, delta, [message])848   *849   * Asserts that the target is equal `expected`, to within a +/- `delta` range.850   *851   *     assert.closeTo(1.5, 1, 0.5, 'numbers are close');852   *853   * @name closeTo854   * @param {Number} actual855   * @param {Number} expected856   * @param {Number} delta857   * @param {String} message858   * @api public859   */860  assert.closeTo = function (act, exp, delta, msg) {861    new Assertion(act, msg).to.be.closeTo(exp, delta);862  };863  /*!864   * Undocumented / untested865   */866  assert.ifError = function (val, msg) {867    new Assertion(val, msg).to.not.be.ok;868  };869  /*!870   * Aliases.871   */872  (function alias(name, as){873    assert[as] = assert[name];874    return alias;875  })876  ('Throw', 'throw')877  ('Throw', 'throws');...

Full Screen

Full Screen

orders.js

Source:orders.js Github

copy

Full Screen

1"use strict";2var assert = require("assert");3var async = require("async");4var request = require("supertest");5var describeAppTest = require("../../../api-app");6var each = require('underscore').each;7var keys = require('underscore').keys;8var pick = require('underscore').pick;9var Project = require('../../../../lib/project');10var Order = require('../../../../lib/order');11var owner = '810ffb30-1938-11e6-a132-dd99bc746802';12describeAppTest("http", function (app) {13  describe('api order routes', function () {14    this.timeout(15000);15    var projectId = 'project-fe5b5340-8991-11e6-b86a-b5fa2a5eb9ca';16    var orderId0 = 'fe5b5340-8991-11e6-b86a-b5fa2a5eb9ca';17    var orderId1 = 'fe5b5340-8971-11e6-b86a-b5fa2a5eb9ca';18    var orderId2 = 'fe5b5340-8931-11e6-b86a-b5fa2a5eb9ca';19    var projectUUID0 = null;20    var projectUUID1 = null;21    var orderUUID0 = null;22    var orderUUID1 = null;23    var orderUUID2 = null;24    before(function (done) {25      async.series([26        function (cb) {27          request(app.proxy)28            .post('/api/projects')29            .send({30              owner: owner,31              id: projectId,32              data: {33                foo: "bar",34                yes: "no",35                counts: {36                  "1": 10,37                  "2": 47,38                },39              },40            })41            .expect(200)42            .end(function (err, res) {43              assert.ifError(err);44              assert.notEqual(res, null);45              assert.notEqual(res.body, null);46              assert.notEqual(res.body.uuid, null);47              projectUUID0 = res.body.uuid;48              return cb(err);49            });50        },51        function (cb) {52          request(app.proxy)53            .post('/api/projects/' + projectId)54            .send({55              data: {56                foo: "bar",57                yes: "no",58                counts: {59                  "1": 10,60                  "2": 47,61                  "3": 578,62                },63                what: "happened",64              },65            })66            .expect(200)67            .end(function (err, res) {68              assert.ifError(err);69              assert.notEqual(res, null);70              assert.notEqual(res.body, null);71              assert.notEqual(res.body.uuid, projectUUID0);72              assert.equal(res.body.version, 1);73              return cb(err);74            });75        },76      ], function (err) {77        assert.ifError(err);78        done();79      });80    });81    after(function (done) {82      async.series([83        function (cb) {84          Order.destroy({85            where: {86              owner: owner,87            },88          }).then(function (numDeleted) {89            console.log('deleted ' + numDeleted + ' orders');90            cb();91          }).catch(function (err) {92            console.error('order cleanup error', err);93            cb(err);94          });95        },96        function (cb) {97          Project.destroy({98            where: {99              owner: owner,100            },101          }).then(function (numDeleted) {102            console.log('deleted ' + numDeleted + ' projects');103            cb();104          }).catch(function (err) {105            console.error('project cleanup error', err);106            cb(err);107          });108        },109      ], function (err) {110        assert.ifError(err);111        done();112      });113    });114    it('should create an order', function createOrder(done) {115      var orderData = {116        owner: owner,117        id: orderId0,118        projectId: projectId,119        projectVersion: 0,120        type: "test",121        data: {122          test: true,123          hello: "kitty",124          stuff: ["bing", "bang", "bong"],125          worldSeries: "cubs",126        },127      };128      request(app.proxy)129        .post('/api/orders')130        .send(orderData)131        .expect(200)132        .end(function (err, res) {133          assert.ifError(err);134          assert.notEqual(res, null);135          assert.notEqual(res.body, null);136          assert.notEqual(res.body.uuid, null);137          orderUUID0 = res.body.uuid;138          // console.log(res.body);139          assert.deepEqual(pick(res.body, keys(orderData)), orderData);140          assert.notEqual(res.body.projectUUID, null);141          assert.notEqual(res.body.createdAt, null);142          assert.notEqual(res.body.updatedAt, null);143          done();144        });145    });146    it('should check if order exists for an id', function checkById(done) {147      request(app.proxy)148        .head('/api/orders/id/' + orderId0)149        .expect(200)150        .end(function (err, res) {151          assert.ifError(err);152          assert.notEqual(res, null);153          var uuidHeader = res.get('Order-UUID');154          assert.equal(uuidHeader, orderUUID0);155          done();156        });157    });158    it('should check if order exists for an id and owner', function checkById(done) {159      request(app.proxy)160        .head('/api/orders/id/' + orderId0 + '?owner=fe5b5340-8971-11e6-b86a-b5fa2a5eb9ca')161        .expect(404)162        .end(function (err) {163          assert.ifError(err);164          done();165        });166    });167    it('should create an order with most recent version', function createOrderMostRecent(done) {168      var orderData = {169        owner: owner,170        id: orderId1,171        projectId: projectId,172        type: "test",173        data: {174          test: true,175          hello: "kitty",176          stuff: ["bing", "bang", "bong"],177          worldSeries: "cubs",178          version: "latest",179        },180      };181      request(app.proxy)182        .post('/api/orders')183        .send(orderData)184        .expect(200)185        .end(function (err, res) {186          assert.ifError(err);187          assert.notEqual(res, null);188          assert.notEqual(res.body, null);189          assert.notEqual(res.body.uuid, null);190          assert.notEqual(res.body.uuid, orderUUID0);191          orderUUID1 = res.body.uuid;192          // console.log(res.body);193          assert.deepEqual(pick(res.body, keys(orderData)), orderData);194          assert.equal(res.body.projectVersion, 1);195          assert.notEqual(res.body.projectUUID, null);196          assert.notEqual(res.body.createdAt, null);197          assert.notEqual(res.body.updatedAt, null);198          done();199        });200    });201    it('should fetch an order using UUID', function fetchByUUID(done) {202      request(app.proxy)203        .get('/api/orders/uuid/' + orderUUID0)204        .expect(200)205        .end(function (err, res) {206          assert.ifError(err);207          assert.notEqual(res, null);208          assert.notEqual(res.body, null);209          assert.equal(res.body.uuid, orderUUID0);210          assert.equal(res.body.id, orderId0);211          assert.notEqual(res.body.projectUUID, null);212          assert.notEqual(res.body.updatedAt, null);213          assert.notEqual(res.body.createdAt, null);214          assert.equal(res.body.type, "test");215          assert.notEqual(res.body.data, null);216          assert.equal(res.body.projectId, projectId);217          assert.notEqual(res.body.projectVersion, null);218          done();219        });220    });221    it('should fetch an order using id', function fetchByUUID(done) {222      request(app.proxy)223        .get('/api/orders/id/' + orderId0)224        .expect(200)225        .end(function (err, res) {226          assert.ifError(err);227          assert.notEqual(res, null);228          assert.notEqual(res.body, null);229          assert.equal(res.body.uuid, orderUUID0);230          assert.notEqual(res.body.projectUUID, null);231          assert.notEqual(res.body.updatedAt, null);232          assert.notEqual(res.body.createdAt, null);233          assert.equal(res.body.type, "test");234          assert.notEqual(res.body.data, null);235          assert.equal(res.body.projectId, projectId);236          assert.notEqual(res.body.projectVersion, null);237          done();238        });239    });240    it('should update order for the same version', function updateSameVersion(done) {241      var orderData = {242        owner: owner,243        id: orderId0,244        projectId: projectId,245        projectVersion: 0,246        type: "order",247        data: {248          test: true,249          hello: "kitty",250          stuff: ["bing", "bang", "bong", "BOOM"],251          worldSeries: "cubs",252          fuzzy: "dice",253        },254      };255      request(app.proxy)256        .post('/api/orders')257        .send(orderData)258        .expect(200)259        .end(function (err, res) {260          assert.ifError(err);261          assert.notEqual(res, null);262          assert.notEqual(res.body, null);263          assert.equal(res.body.uuid, orderUUID0);264          // console.log(res.body);265          assert.equal(res.body.type, "order");266          assert.deepEqual(res.body.data, orderData.data);267          done();268        });269    });270    it('should create a new order for new version of same project', function createNewVersion(done) {271      async.waterfall([272        function (cb) {273          var newProjectData = {274            foo: "bar",275            yes: "no",276            counts: {277              "1": 10,278              "2": 47,279            },280          };281          request(app.proxy)282            .post('/api/projects/' + projectId)283            .send({284              data: newProjectData,285            })286            .expect(200)287            .end(function (err, res) {288              assert.ifError(err);289              assert.notEqual(res, null);290              assert.notEqual(res.body, null);291              // console.log('update result:', res.body);292              assert.deepEqual(res.body.data, newProjectData);293              assert(res.body.version > 0);294              cb(null, res.body.version);295            });296        },297        function (newVersion, cb) {298          var newOrderData = {299            owner: owner,300            id: orderId2,301            projectId: projectId,302            projectVersion: newVersion,303            type: "test",304            data: {305              test: true,306              hello: "kitty",307              stuff: ["ying", "yang"],308            },309          };310          request(app.proxy)311            .post('/api/orders')312            .send(newOrderData)313            .expect(200)314            .end(function (err, res) {315              assert.ifError(err);316              assert.notEqual(res, null);317              assert.notEqual(res.body, null);318              assert.equal(res.body.id, orderId2);319              assert.notEqual(res.body.uuid, null);320              orderUUID2 = res.body.uuid;321              // console.log(res.body);322              assert.deepEqual(pick(res.body, keys(newOrderData)), newOrderData);323              assert.notEqual(res.body.projectUUID, null);324              assert.notEqual(res.body.createdAt, null);325              assert.notEqual(res.body.updatedAt, null);326              cb(null, null);327            });328        },329      ], function (err) {330        assert.ifError(err);331        done();332      });333    });334    it('should return 404 for fetch of non-existing order', function fetchNotExist(done) {335      request(app.proxy)336        .get('/api/orders/blah')337        .expect(404)338        .end(function (err, res) {339          assert.ifError(err);340          assert.notEqual(res, null);341          assert.notEqual(res.body, null);342          assert.notEqual(res.body.message, null);343          done();344        });345    });346    it('should fetch all orders for a project', function fetchAllOrders(done) {347      request(app.proxy)348        .get('/api/orders/' + projectId)349        .expect(200)350        .end(function (err, res) {351          assert.ifError(err);352          assert.notEqual(res, null);353          assert.notEqual(res.body, null);354          assert(Array.isArray(res.body));355          var orders = res.body;356          assert.equal(orders.length, 3);357          each(orders, function (order) {358            assert.notEqual(order.projectUUID, null);359            assert.notEqual(order.updatedAt, null);360            assert.notEqual(order.createdAt, null);361            assert.notEqual(order.type, null);362            assert.notEqual(order.data, null);363            assert.equal(order.projectId, projectId);364            assert.notEqual(order.projectVersion, null);365          });366          done();367        });368    });369    it('should fetch one order for one project version', function fetchOneOrder(done) {370      request(app.proxy)371        .get('/api/orders/' + projectId + '?version=0')372        .expect(200)373        .end(function (err, res) {374          assert.ifError(err);375          assert.notEqual(res, null);376          assert.notEqual(res.body, null);377          assert(Array.isArray(res.body));378          var orders = res.body;379          assert.equal(orders.length, 1);380          var order = orders[0];381          assert.notEqual(order.projectUUID, null);382          assert.notEqual(order.updatedAt, null);383          assert.notEqual(order.createdAt, null);384          assert.equal(order.type, "order");385          assert.notEqual(order.data, null);386          assert.equal(order.projectId, projectId);387          assert.equal(order.projectVersion, 0);388          done();389        });390    });391    it('should return 404 for existence check for non-existing project', function testOrderExistsFail(done) {392      request(app.proxy)393        .head('/api/orders/aaaabbbba')394        .expect(404)395        .end(function (err, res) {396          assert.ifError(err);397          done();398        });399    });400    it('should check exists of orders for a project', function testOrdersExist(done) {401      async.waterfall([402        function (cb) {403          request(app.proxy)404            .head('/api/orders/' + projectId)405            .expect(200)406            .end(function (err, res) {407              assert.ifError(err);408              assert.notEqual(res, null);409              var latestOrderId = res.get('Latest-Order-Id');410              assert.notEqual(latestOrderId, null);411              var latestOrderUUID = res.get('Latest-Order-UUID');412              assert.notEqual(latestOrderUUID, null);413              cb(err, {414                uuid: latestOrderUUID,415                id: latestOrderId,416              });417            });418        },419        function (latestOrder, cb) {420          request(app.proxy)421            .get('/api/orders/uuid/' + latestOrder.uuid)422            .expect(200)423            .end(function (err, res) {424              assert.ifError(err);425              assert.notEqual(res, null);426              assert.notEqual(res.body, null);427              assert.equal(res.body.uuid, latestOrder.uuid);428              assert.equal(res.body.id, latestOrder.id);429              assert.notEqual(res.body.projectUUID, null);430              assert.notEqual(res.body.updatedAt, null);431              assert.notEqual(res.body.createdAt, null);432              assert.equal(res.body.type, "test");433              assert.notEqual(res.body.data, null);434              assert.equal(res.body.projectId, projectId);435              assert.notEqual(res.body.projectVersion, null);436              cb(err, latestOrder);437            });438        },439        function (latestOrder, cb) {440          request(app.proxy)441            .get('/api/orders/id/' + latestOrder.id)442            .expect(200)443            .end(function (err, res) {444              assert.ifError(err);445              assert.notEqual(res, null);446              assert.notEqual(res.body, null);447              assert.equal(res.body.uuid, latestOrder.uuid);448              assert.equal(res.body.id, latestOrder.id);449              assert.notEqual(res.body.projectUUID, null);450              assert.notEqual(res.body.updatedAt, null);451              assert.notEqual(res.body.createdAt, null);452              assert.equal(res.body.type, "test");453              assert.notEqual(res.body.data, null);454              assert.equal(res.body.projectId, projectId);455              assert.notEqual(res.body.projectVersion, null);456              cb(err, latestOrder);457            });458        },459      ], function (err) {460        assert.ifError(err);461        done();462      });463    });464    it('should delete an order by UUID', function deleteByUUID(done) {465      async.series([466        function (cb) {467          request(app.proxy)468            .delete('/api/orders/uuid/' + orderUUID0)469            .expect(200)470            .end(function (err, res) {471              assert.ifError(err);472              assert.notEqual(res, null);473              assert.notEqual(res.body, null);474              assert.equal(res.body.numDeleted, 1);475              cb(err);476            });477        },478        function (cb) {479          request(app.proxy)480            .get('/api/orders/uuid/' + orderUUID0)481            .expect(404)482            .end(function (err, res) {483              assert.ifError(err);484              cb(err);485            });486        },487        function (cb) {488          Order.findOne({489            where: {490              uuid: orderUUID0,491            }492          }).then(function (result) {493            assert.notEqual(result, null);494            assert.equal(result.get('status'), 0);495            cb(null);496          }).catch(cb);497        },498      ], function (err) {499        assert.ifError(err);500        done();501      });502    });503    it('should destroy an order by UUID', function destroyByUUID(done) {504      async.series([505        function (cb) {506          request(app.proxy)507            .delete('/api/orders/uuid/' + orderUUID2 + '?destroy=true')508            .expect(200)509            .end(function (err, res) {510              assert.ifError(err);511              assert.notEqual(res, null);512              assert.notEqual(res.body, null);513              assert.equal(res.body.numDeleted, 1);514              cb(err);515            });516        },517        function (cb) {518          request(app.proxy)519            .get('/api/orders/uuid/' + orderUUID2)520            .expect(404)521            .end(function (err, res) {522              assert.ifError(err);523              cb(err);524            });525        },526        function (cb) {527          Order.findOne({528            where: {529              uuid: orderUUID2,530            }531          }).then(function (result) {532            assert.equal(result, null);533            cb(null);534          }).catch(cb);535        },536      ], function (err) {537        assert.ifError(err);538        done();539      });540    });541    it('should delete an order by id', function deleteByOrderId(done) {542      async.series([543        function (cb) {544          request(app.proxy)545            .delete('/api/orders/id/' + orderId1)546            .expect(200)547            .end(function (err, res) {548              assert.ifError(err);549              assert.notEqual(res, null);550              assert.notEqual(res.body, null);551              assert.equal(res.body.numDeleted, 1);552              cb(err);553            });554        },555        function (cb) {556          request(app.proxy)557            .get('/api/orders/id/' + orderId1)558            .expect(404)559            .end(function (err, res) {560              assert.ifError(err);561              cb(err);562            });563        },564        function (cb) {565          Order.findOne({566            where: {567              id: orderId1,568              owner: owner,569            }570          }).then(function (result) {571            assert.notEqual(result, null);572            assert.equal(result.get('status'), 0);573            cb(null);574          }).catch(cb);575        },576      ], function (err) {577        assert.ifError(err);578        done();579      });580    });581    it('should destroy an order by id and owner', function destroyByOrderId(done) {582      async.series([583        function (cb) {584          request(app.proxy)585            .delete('/api/orders/id/' + orderId1 + '?destroy=true' + '&owner=' + owner)586            .expect(200)587            .end(function (err, res) {588              assert.ifError(err);589              assert.notEqual(res, null);590              assert.notEqual(res.body, null);591              assert.equal(res.body.numDeleted, 1);592              cb(err);593            });594        },595        function (cb) {596          Order.findOne({597            where: {598              id: orderId1,599              owner: owner,600            }601          }).then(function (result) {602            assert.equal(result, null);603            cb(null);604          }).catch(cb);605        },606      ], function (err) {607        assert.ifError(err);608        done();609      });610    });611  });...

Full Screen

Full Screen

snapshots.js

Source:snapshots.js Github

copy

Full Screen

1"use strict";2var assert = require("assert");3var async = require("async");4var request = require("supertest");5var describeAppTest = require("../../../api-app");6var each = require('underscore').each;7var keys = require('underscore').keys;8var pick = require('underscore').pick;9var Project = require('../../../../lib/project');10var Snapshot = require('../../../../lib/snapshot');11var owner = '810ffb30-1938-11e6-a132-dd99bc746800';12describeAppTest("http", function (app) {13  describe('api snapshot routes', function () {14    this.timeout(15000);15    var projectId = 'project-fe5b5340-8991-11e6-b86a-b5fa2a5eb9ca';16    var projectUUID0 = null;17    var projectUUID1 = null;18    var snapshotUUID0 = null;19    var snapshotUUID1 = null;20    before(function (done) {21      async.series([22        function (cb) {23          request(app.proxy)24            .post('/api/projects')25            .send({26              owner: owner,27              id: projectId,28              data: {29                foo: "bar",30                yes: "no",31                counts: {32                  "1": 10,33                  "2": 47,34                },35              },36            })37            .expect(200)38            .end(function (err, res) {39              assert.ifError(err);40              assert.notEqual(res, null);41              assert.notEqual(res.body, null);42              assert.notEqual(res.body.uuid, null);43              projectUUID0 = res.body.uuid;44              return cb(err);45            });46        },47        function (cb) {48          request(app.proxy)49            .post('/api/projects/' + projectId)50            .send({51              data: {52                foo: "bar",53                yes: "no",54                counts: {55                  "1": 10,56                  "2": 47,57                  "3": 578,58                },59                what: "happened",60              },61            })62            .expect(200)63            .end(function (err, res) {64              assert.ifError(err);65              assert.notEqual(res, null);66              assert.notEqual(res.body, null);67              assert.notEqual(res.body.uuid, projectUUID0);68              assert.equal(res.body.version, 1);69              return cb(err);70            });71        },72      ], function (err) {73        assert.ifError(err);74        done();75      });76    });77    after(function (done) {78      async.series([79        function (cb) {80          Snapshot.destroy({81            where: {82              owner: owner,83            },84          }).then(function (numDeleted) {85            console.log('deleted ' + numDeleted + ' snapshots');86            cb();87          }).catch(function (err) {88            console.error('snapshot cleanup error', err);89            cb(err);90          });91        },92        function (cb) {93          Project.destroy({94            where: {95              owner: owner,96            },97          }).then(function (numDeleted) {98            console.log('deleted ' + numDeleted + ' projects');99            cb();100          }).catch(function (err) {101            console.error('project cleanup error', err);102            cb(err);103          });104        },105      ], function (err) {106        assert.ifError(err);107        done();108      });109    });110    it('should create a snapshot', function createSnapshot(done) {111      var data = {112        owner: owner,113        projectId: projectId,114        projectVersion: 0,115        message: "test snapshot",116        type: "test",117        tags: {118          test: true,119          hello: "kitty",120          stuff: ["bing", "bang", "bong"],121          worldSeries: "cubs",122        },123      };124      request(app.proxy)125        .post('/api/snapshots')126        .send(data)127        .expect(200)128        .end(function (err, res) {129          assert.ifError(err);130          assert.notEqual(res, null);131          assert.notEqual(res.body, null);132          assert.notEqual(res.body.uuid, null);133          snapshotUUID0 = res.body.uuid;134          // console.log(res.body);135          assert.deepEqual(pick(res.body, keys(data)), data);136          assert.notEqual(res.body.projectUUID, null);137          assert.notEqual(res.body.createdAt, null);138          assert.notEqual(res.body.updatedAt, null);139          done();140        });141    });142    it('should create a snapshot with most recent version', function createSnapshotMostRecent(done) {143      var data = {144        owner: owner,145        projectId: projectId,146        message: "test snapshot v1",147        type: "test",148        tags: {149          test: true,150          hello: "kitty",151          stuff: ["bing", "bang", "bong"],152          worldSeries: "cubs",153          version: "latest",154        },155      };156      request(app.proxy)157        .post('/api/snapshots')158        .send(data)159        .expect(200)160        .end(function (err, res) {161          assert.ifError(err);162          assert.notEqual(res, null);163          assert.notEqual(res.body, null);164          assert.notEqual(res.body.uuid, null);165          assert.notEqual(res.body.uuid, snapshotUUID0);166          // console.log(res.body);167          assert.deepEqual(pick(res.body, keys(data)), data);168          assert.equal(res.body.projectVersion, 1);169          assert.notEqual(res.body.projectUUID, null);170          assert.notEqual(res.body.createdAt, null);171          assert.notEqual(res.body.updatedAt, null);172          done();173        });174    });175    it('should fetch a snaphost using UUID', function fetchByUUID(done) {176      request(app.proxy)177        .get('/api/snapshots/uuid/' + snapshotUUID0)178        .expect(200)179        .end(function (err, res) {180          assert.ifError(err);181          assert.notEqual(res, null);182          assert.notEqual(res.body, null);183          assert.equal(res.body.uuid, snapshotUUID0);184          assert.notEqual(res.body.projectUUID, null);185          assert.notEqual(res.body.updatedAt, null);186          assert.notEqual(res.body.createdAt, null);187          assert.equal(res.body.type, "test");188          assert.notEqual(res.body.message, null);189          assert.notEqual(res.body.tags, null);190          assert.equal(res.body.projectId, projectId);191          assert.notEqual(res.body.projectVersion, null);192          done();193        });194    });195    it('should update snapshot for the same version', function updateSameVersion(done) {196      var data = {197        owner: owner,198        projectId: projectId,199        projectVersion: 0,200        message: "updated test snapshot",201        type: "order",202        tags: {203          test: true,204          hello: "kitty",205          stuff: ["bing", "bang", "bong", "BOOM"],206          worldSeries: "cubs",207          fuzzy: "dice",208        },209      };210      request(app.proxy)211        .post('/api/snapshots')212        .send(data)213        .expect(200)214        .end(function (err, res) {215          assert.ifError(err);216          assert.notEqual(res, null);217          assert.notEqual(res.body, null);218          assert.equal(res.body.uuid, snapshotUUID0);219          // console.log(res.body);220          assert.equal(res.body.type, "order");221          assert.equal(res.body.message, data.message);222          assert.deepEqual(res.body.tags, data.tags);223          done();224        });225    });226    it('should create a new snapshot for new version of same project', function createNewVersion(done) {227      async.waterfall([228        function (cb) {229          var newProjectData = {230            foo: "bar",231            yes: "no",232            counts: {233              "1": 10,234              "2": 47,235            },236          };237          request(app.proxy)238            .post('/api/projects/' + projectId)239            .send({240              data: newProjectData,241            })242            .expect(200)243            .end(function (err, res) {244              assert.ifError(err);245              assert.notEqual(res, null);246              assert.notEqual(res.body, null);247              // console.log('update result:', res.body);248              assert.deepEqual(res.body.data, newProjectData);249              assert(res.body.version > 0);250              cb(null, res.body.version);251            });252        },253        function (newVersion, cb) {254          var newSnapshotData = {255            owner: owner,256            projectId: projectId,257            projectVersion: newVersion,258            message: "new test snapshot",259            type: "test",260            tags: {261              test: true,262              hello: "kitty",263              stuff: ["ying", "yang"],264            },265          };266          request(app.proxy)267            .post('/api/snapshots')268            .send(newSnapshotData)269            .expect(200)270            .end(function (err, res) {271              assert.ifError(err);272              assert.notEqual(res, null);273              assert.notEqual(res.body, null);274              assert.notEqual(res.body.uuid, null);275              snapshotUUID1 = res.body.uuid;276              // console.log(res.body);277              assert.deepEqual(pick(res.body, keys(newSnapshotData)), newSnapshotData);278              assert.notEqual(res.body.projectUUID, null);279              assert.notEqual(res.body.createdAt, null);280              assert.notEqual(res.body.updatedAt, null);281              cb(null, null);282            });283        },284      ], function (err) {285        assert.ifError(err);286        done();287      });288    });289    it('should return 404 for fetch of non-existing snapshot', function fetchNotExist(done) {290      request(app.proxy)291        .get('/api/snapshots/blah')292        .expect(404)293        .end(function (err, res) {294          assert.ifError(err);295          assert.notEqual(res, null);296          assert.notEqual(res.body, null);297          assert.notEqual(res.body.message, null);298          done();299        });300    });301    it('should fetch all snapshots for a project', function fetchAllSnapshots(done) {302      request(app.proxy)303        .get('/api/snapshots/' + projectId)304        .expect(200)305        .end(function (err, res) {306          assert.ifError(err);307          assert.notEqual(res, null);308          assert.notEqual(res.body, null);309          assert(Array.isArray(res.body));310          var snapshots = res.body;311          assert.equal(snapshots.length, 3);312          each(snapshots, function (snapshot) {313            assert.notEqual(snapshot.projectUUID, null);314            assert.notEqual(snapshot.updatedAt, null);315            assert.notEqual(snapshot.createdAt, null);316            assert.notEqual(snapshot.type, null);317            assert.notEqual(snapshot.message, null);318            assert.notEqual(snapshot.tags, null);319            assert.equal(snapshot.projectId, projectId);320            assert.notEqual(snapshot.projectVersion, null);321          });322          done();323        });324    });325    it('should fetch one snapshot for one project version', function fetchOneSnapshot(done) {326      request(app.proxy)327        .get('/api/snapshots/' + projectId + '?version=0')328        .expect(200)329        .end(function (err, res) {330          assert.ifError(err);331          assert.notEqual(res, null);332          assert.notEqual(res.body, null);333          assert(Array.isArray(res.body));334          var snapshots = res.body;335          assert.equal(snapshots.length, 1);336          var snapshot = snapshots[0];337          assert.notEqual(snapshot.projectUUID, null);338          assert.notEqual(snapshot.updatedAt, null);339          assert.notEqual(snapshot.createdAt, null);340          assert.equal(snapshot.type, "order");341          assert.notEqual(snapshot.message, null);342          assert.notEqual(snapshot.tags, null);343          assert.equal(snapshot.projectId, projectId);344          assert.equal(snapshot.projectVersion, 0);345          done();346        });347    });348    it('should return 404 for existence check for non-existing project', function testSnapshotExistsFail(done) {349      request(app.proxy)350        .head('/api/snapshots/aaaabbbba')351        .expect(404)352        .end(function (err, res) {353          assert.ifError(err);354          done();355        });356    });357    it('should check exists of snapshots for a project', function testSnapshotsExist(done) {358      async.waterfall([359        function (cb) {360          request(app.proxy)361            .head('/api/snapshots/' + projectId)362            .expect(200)363            .end(function (err, res) {364              assert.ifError(err);365              assert.notEqual(res, null);366              var latestSnapshot = res.get('Latest-Snapshot');367              assert.notEqual(latestSnapshot, null);368              cb(null, latestSnapshot);369            });370        },371        function (latestSnapshot, cb) {372          request(app.proxy)373            .get('/api/snapshots/uuid/' + latestSnapshot)374            .expect(200)375            .end(function (err, res) {376              assert.ifError(err);377              assert.notEqual(res, null);378              assert.notEqual(res.body, null);379              assert.equal(res.body.uuid, latestSnapshot);380              assert.notEqual(res.body.projectUUID, null);381              assert.notEqual(res.body.updatedAt, null);382              assert.notEqual(res.body.createdAt, null);383              assert.equal(res.body.type, "test");384              assert.notEqual(res.body.message, null);385              assert.notEqual(res.body.tags, null);386              assert.equal(res.body.projectId, projectId);387              assert.notEqual(res.body.projectVersion, null);388              cb(null, null);389            });390        },391      ], function (err) {392        assert.ifError(err);393        done();394      });395    });396    it('should fetch snapshots with tags', function fetchByTags(done) {397      request(app.proxy)398        .post('/api/snapshots/tags')399        .send({400          hello: "kitty",401        })402        .expect(200)403        .end(function (err, res) {404          assert.ifError(err);405          assert.notEqual(res, null);406          assert.notEqual(res.body, null);407          assert(Array.isArray(res.body));408          var snapshots = res.body;409          assert.equal(snapshots.length, 3);410          each(snapshots, function (snapshot) {411            assert.notEqual(snapshot.projectUUID, null);412            assert.notEqual(snapshot.updatedAt, null);413            assert.notEqual(snapshot.createdAt, null);414            assert.notEqual(snapshot.type, null);415            assert.notEqual(snapshot.message, null);416            assert.notEqual(snapshot.tags, null);417            assert.equal(snapshot.projectId, projectId);418            assert.notEqual(snapshot.projectVersion, null);419          });420          done();421        });422    });423    it('should fetch snapshots with tags and projectId', function fetchByTagsProjectId(done) {424      request(app.proxy)425        .post('/api/snapshots/tags' + '?project=' + projectId)426        .send({427          test: true,428        })429        .expect(200)430        .end(function (err, res) {431          assert.ifError(err);432          assert.notEqual(res, null);433          assert.notEqual(res.body, null);434          assert(Array.isArray(res.body));435          var snapshots = res.body;436          assert.equal(snapshots.length, 3);437          each(snapshots, function (snapshot) {438            assert.notEqual(snapshot.projectUUID, null);439            assert.notEqual(snapshot.updatedAt, null);440            assert.notEqual(snapshot.createdAt, null);441            assert.notEqual(snapshot.type, null);442            assert.notEqual(snapshot.message, null);443            assert.notEqual(snapshot.tags, null);444            assert.equal(snapshot.projectId, projectId);445            assert.notEqual(snapshot.projectVersion, null);446          });447          done();448        });449    });450    it('should fetch one snapshot with tags', function fetchOneWithTags(done) {451      request(app.proxy)452        .post('/api/snapshots/tags')453        .send({454          fuzzy: "dice",455        })456        .expect(200)457        .end(function (err, res) {458          assert.ifError(err);459          assert.notEqual(res, null);460          assert.notEqual(res.body, null);461          assert(Array.isArray(res.body));462          var snapshots = res.body;463          assert.equal(snapshots.length, 1);464          each(snapshots, function (snapshot) {465            assert.notEqual(snapshot.projectUUID, null);466            assert.notEqual(snapshot.updatedAt, null);467            assert.notEqual(snapshot.createdAt, null);468            assert.notEqual(snapshot.type, null);469            assert.notEqual(snapshot.message, null);470            assert.notEqual(snapshot.tags, null);471            assert.equal(snapshot.projectId, projectId);472            assert.notEqual(snapshot.projectVersion, null);473          });474          done();475        });476    });477    it('should return 404 fetch snapshots with junk tags', function fetchByTagsFail(done) {478      request(app.proxy)479        .post('/api/snapshots/tags')480        .send({481          pink: "flamingo",482        })483        .expect(404)484        .end(function (err, res) {485          assert.ifError(err);486          assert.notEqual(res, null);487          assert.notEqual(res.body, null);488          assert.notEqual(res.body.message, null);489          done();490        });491    });492    it('should delete a snapshot by UUID', function deleteByUUID(done) {493      async.series([494        function (cb) {495          request(app.proxy)496            .delete('/api/snapshots/uuid/' + snapshotUUID0)497            .expect(200)498            .end(function (err, res) {499              assert.ifError(err);500              assert.notEqual(res, null);501              assert.notEqual(res.body, null);502              assert.equal(res.body.numDeleted, 1);503              cb(err);504            });505        },506        function (cb) {507          request(app.proxy)508            .get('/api/snapshots/uuid/' + snapshotUUID0)509            .expect(404)510            .end(function (err, res) {511              assert.ifError(err);512              cb(err);513            });514        },515        function (cb) {516          Snapshot.findOne({517            where: {518              uuid: snapshotUUID0,519            }520          }).then(function (result) {521            assert.notEqual(result, null);522            assert.equal(result.get('status'), 0);523            cb(null);524          }).catch(cb);525        },526      ], function (err) {527        assert.ifError(err);528        done();529      });530    });531    it('should destroy a snapshot by UUID', function destroyByUUID(done) {532      async.series([533        function (cb) {534          request(app.proxy)535            .delete('/api/snapshots/uuid/' + snapshotUUID1 + '?destroy=true')536            .expect(200)537            .end(function (err, res) {538              assert.ifError(err);539              assert.notEqual(res, null);540              assert.notEqual(res.body, null);541              assert.equal(res.body.numDeleted, 1);542              cb(err);543            });544        },545        function (cb) {546          request(app.proxy)547            .get('/api/snapshots/uuid/' + snapshotUUID1)548            .expect(404)549            .end(function (err, res) {550              assert.ifError(err);551              cb(err);552            });553        },554        function (cb) {555          Snapshot.findOne({556            where: {557              uuid: snapshotUUID1,558            }559          }).then(function (result) {560            assert.equal(result, null);561            cb(null);562          }).catch(cb);563        },564      ], function (err) {565        assert.ifError(err);566        done();567      });568    });569  });...

Full Screen

Full Screen

RegisterCompo.js

Source:RegisterCompo.js Github

copy

Full Screen

1import React, { useState, useEffect, useContext } from 'react'2import Avatar from '@mui/material/Avatar';3import Button from '@mui/material/Button';4import CssBaseline from '@mui/material/CssBaseline';5import TextField from '@mui/material/TextField';6import FormControlLabel from '@mui/material/FormControlLabel';7import Checkbox from '@mui/material/Checkbox';8import Link from '@mui/material/Link';9import Grid from '@mui/material/Grid';10import Box from '@mui/material/Box';11import LockOutlinedIcon from '@mui/icons-material/LockOutlined';12import Typography from '@mui/material/Typography';13import makeStyles from '@mui/styles/makeStyles';14import Container from '@mui/material/Container';15import Radio from '@mui/material/Radio';16import RadioGroup from '@mui/material/RadioGroup';17import { hostname } from "../hostname";18import FormHelperText from '@mui/material/FormHelperText';19import axios from "axios";20import { useHistory } from 'react-router-dom'21import Snackbar from './snackbar';22const useStyles = makeStyles((theme) => ({23    paper: {24        marginTop: theme.spacing(8),25        display: 'flex',26        flexDirection: 'column',27        alignItems: 'center',28    },29    avatar: {30        margin: theme.spacing(1),31        backgroundColor: theme.palette.secondary.main,32    },33    form: {34        width: '100%', // Fix IE 11 issue.35        marginTop: theme.spacing(3),36    },37    submit: {38        margin: theme.spacing(3, 0, 2),39    },40}));41function RegisterCompo() {42    const [openSnackbar, setOpenSnackbar] = useState({ status: false, type: "", msg: "" });43    const history = useHistory()44    const classes = useStyles();45    const [firstname, setFirstname] = useState("");46    const [lastname, setLastname] = useState("");47    const [username, setUsername] = useState("");48    const [password, setPassword] = useState("");49    const [roleId, setRoleId] = useState("");50    const [confirmPassword, setConfirmPassword] = useState("");51    const [passwordNotMatch, setPasswordNotMatch] = useState("");52    const [errorPasswordNotMatch, setErrorPasswordNotMatch] = useState(false);53    const [notSelectRole, setNotSelectRole] = useState("")54    const [errorNotSelectRole, setErrorNotSelectRole] = useState(false)55    const [notInputUsername, setNotInputUsername] = useState("")56    const [errorNotInputUsername, setErrorNotInputUsername] = useState(false)57    const [notInputPassword, setNotInputPassword] = useState("")58    const [errorNotInputPassword, setErrorNotInputPassword] = useState(false)59    const [notInputFirstname, setNotInputFirstname] = useState("")60    const [errorNotInputFirstname, setErrorNotInputFirstname] = useState(false)61    const [notInputLastname, setNotInputLastname] = useState("")62    const [errorNotInputLastname, setErrorNotInputLastname] = useState(false)63    const handleSignUpSubmit = async e => {64        e.preventDefault();65        validate()66        if (firstname !== "" && lastname !== "" && username !== "" && password !== "" && confirmPassword !== "" && roleId !== "") {67            if (errorNotInputFirstname !== true && errorNotInputLastname !== true && errorNotInputUsername !== true68                && errorNotInputPassword !== true && errorPasswordNotMatch !== true && errorNotSelectRole !== true) {69                registerAPI()70            }71        }72    };73    const validate = () => {74        if (firstname == "") {75            setNotInputFirstname("กรุณากรอกชื่อ")76            setErrorNotInputFirstname(true)77        }78        if (lastname == "") {79            setNotInputLastname("กรุณากรอกนามสกุล")80            setErrorNotInputLastname(true)81        }82        if (username == "") {83            setNotInputUsername("กรุณากรอกชื่อผู้ใช้")84            setErrorNotInputUsername(true)85        }86        if (password == "") {87            setNotInputPassword("กรุณากรอกรหัสผ่าน")88            setErrorNotInputPassword(true)89        }90        if (password !== confirmPassword) {91            setPasswordNotMatch("รหัสผ่านไม่ตรงกัน")92            setErrorPasswordNotMatch(true)93        }94        if (roleId == "") {95            setNotSelectRole("กรุณาเลือกประเภทผู้ใช้")96            setErrorNotSelectRole(true)97        }98    }99    const registerAPI = async () => {100        let res = await axios({101            method: "post",102            url: `${hostname}/register`,103            data: {104                username: username,105                password: password,106                user_firstname: firstname,107                user_lastname: lastname,108                user_role_id: roleId,109            },110        });111        let resStatusData = res.data.status112        if (resStatusData == "registered") {113            resetInputField()114            setOpenSnackbar({ status: true, type: "error", msg: resStatusData });115        } else if (resStatusData == "success") {116            history.push('/login')117            setOpenSnackbar({ status: true, type: "error", msg: "สมัครสมาชิกสำเร็จ" });118        }119    }120    const resetInputField = () => {121        setFirstname("");122        setLastname("");123        setUsername("");124        setPassword("");125        setConfirmPassword("");126        setRoleId("");127        setNotInputFirstname("")128        setNotInputLastname("")129        setNotInputUsername("")130        setNotInputPassword("")131        setPasswordNotMatch("")132        setNotSelectRole("")133    };134    return (135        <>136            <Container component="main" maxWidth="xs">137                <CssBaseline />138                <div className={classes.paper}>139                    <Avatar className={classes.avatar}>140                        <LockOutlinedIcon />141                    </Avatar>142                    <Typography component="h1" variant="h5">143                        สมัครสมาชิก144                    </Typography>145                    <form className={classes.form} autocomplete="off" noValidate onSubmit={handleSignUpSubmit}>146                        <Grid container spacing={2}>147                            <Grid item xs={12} sm={6}>148                                <TextField149                                    variant="outlined"150                                    required151                                    fullWidth152                                    value={firstname}153                                    error={errorNotInputFirstname}154                                    helperText={notInputFirstname}155                                    onChange={(e) => {156                                        setFirstname(e.target.value)157                                        setErrorNotInputFirstname(false)158                                        setNotInputFirstname("")159                                    }}160                                    label="ชื่อ"161                                />162                            </Grid>163                            <Grid item xs={12} sm={6}>164                                <TextField165                                    variant="outlined"166                                    required167                                    value={lastname}168                                    error={errorNotInputLastname}169                                    helperText={notInputLastname}170                                    onChange={(e) => {171                                        setLastname(e.target.value)172                                        setErrorNotInputLastname(false)173                                        setNotInputLastname("")174                                    }}175                                    fullWidth176                                    label="นามสกุล"177                                    name="lastName"178                                />179                            </Grid>180                            <Grid item xs={12}>181                                <TextField182                                    variant="outlined"183                                    required184                                    value={username}185                                    error={errorNotInputUsername}186                                    helperText={notInputUsername}187                                    fullWidth188                                    label="ชื่อผู้ใช้"189                                    onChange={(e) => {190                                        setUsername(e.target.value)191                                        setErrorNotInputUsername(false)192                                        setNotInputUsername("")193                                    }}194                                />195                            </Grid>196                            <Grid item xs={12}>197                                <TextField198                                    variant="outlined"199                                    required200                                    fullWidth201                                    value={password}202                                    error={errorNotInputPassword}203                                    helperText={notInputPassword}204                                    label="รหัสผ่าน"205                                    type="password"206                                    onChange={(e) => {207                                        setPassword(e.target.value)208                                        setErrorNotInputPassword(false)209                                        setNotInputPassword("")210                                    }}211                                />212                            </Grid>213                            <Grid item xs={12}>214                                <TextField215                                    variant="outlined"216                                    required217                                    fullWidth218                                    error={errorPasswordNotMatch}219                                    value={confirmPassword}220                                    label="ยืนยันรหัสผ่าน"221                                    type="password"222                                    helperText={passwordNotMatch}223                                    onChange={(e) => {224                                        setConfirmPassword(e.target.value)225                                        setErrorPasswordNotMatch(false)226                                        setPasswordNotMatch("")227                                    }}228                                />229                            </Grid>230                            <Grid item xs={12} style={{ marginLeft: "25%" }}>231                                <RadioGroup232                                    row aria-label="position"233                                    name="position" onChange={(e) => {234                                        setRoleId(e.target.value)235                                        setNotSelectRole("")236                                        setErrorNotSelectRole(false)237                                    }}238                                    defaultValue="top"239                                    value={roleId}240                                    required241                                    error242                                >243                                    <FormControlLabel244                                        value="1"245                                        control={<Radio color="primary" />}246                                        label="ผู้ใช้ทั่วไป"247                                        labelPlacement="end"248                                    />249                                    <FormControlLabel250                                        value="2"251                                        control={<Radio color="primary" />}252                                        label="ผู้ดูแลวัด" />253                                </RadioGroup>254                                <FormHelperText error={errorNotSelectRole}>{notSelectRole}</FormHelperText>255                            </Grid>256                        </Grid>257                        <Button258                            type="submit"259                            fullWidth260                            variant="contained"261                            color="primary"262                            className={classes.submit}263                        >264                            สมัครสมาชิก265                        </Button>266                        <Grid container justifyContent="flex-end">267                            <Grid item>268                                <Link variant="body2" component="button" onClick={() => history.push('/login')}>269                                    มีบัญชีอยู่แล้ว ? เข้าสู่ระบบ270                                </Link>271                            </Grid>272                        </Grid>273                    </form>274                </div>275                <Box mt={5}>276                </Box>277            </Container>278            <Snackbar values={openSnackbar} setValues={setOpenSnackbar} />279        </>280    )281}...

Full Screen

Full Screen

selector.js

Source:selector.js Github

copy

Full Screen

1/*2 * selector unit tests3 */4(function($) {5module("core - selectors");6function isFocusable(selector, msg) {7	QUnit.push($(selector).is(":focusable"), null, null, msg + " - selector " + selector + " is focusable");8}9function isNotFocusable(selector, msg) {10	QUnit.push($(selector).length && !$(selector).is(":focusable"), null, null, msg + " - selector " + selector + " is not focusable");11}12function isTabbable(selector, msg) {13	QUnit.push($(selector).is(":tabbable"), null, null, msg + " - selector " + selector + " is tabbable");14}15function isNotTabbable(selector, msg) {16	QUnit.push($(selector).length && !$(selector).is(":tabbable"), null, null, msg + " - selector " + selector + " is not tabbable");17}18test("data", function() {19	expect(15);20	var el;21	function shouldHaveData(msg) {22		ok(el.is(":data(test)"), msg);23	}24	function shouldNotHaveData(msg) {25		ok(!el.is(":data(test)"), msg);26	}27	el = $("<div>");28	shouldNotHaveData("data never set");29	el = $("<div>").data("test", null);30	shouldNotHaveData("data is null");31	el = $("<div>").data("test", true);32	shouldHaveData("data set to true");33	el = $("<div>").data("test", false);34	shouldNotHaveData("data set to false");35	el = $("<div>").data("test", 0);36	shouldNotHaveData("data set to 0");37	el = $("<div>").data("test", 1);38	shouldHaveData("data set to 1");39	el = $("<div>").data("test", "");40	shouldNotHaveData("data set to empty string");41	el = $("<div>").data("test", "foo");42	shouldHaveData("data set to string");43	el = $("<div>").data("test", []);44	shouldHaveData("data set to empty array");45	el = $("<div>").data("test", [1]);46	shouldHaveData("data set to array");47	el = $("<div>").data("test", {});48	shouldHaveData("data set to empty object");49	el = $("<div>").data("test", {foo: "bar"});50	shouldHaveData("data set to object");51	el = $("<div>").data("test", new Date());52	shouldHaveData("data set to date");53	el = $("<div>").data("test", /test/);54	shouldHaveData("data set to regexp");55	el = $("<div>").data("test", function() {});56	shouldHaveData("data set to function");57});58test("focusable - visible, enabled elements", function() {59	expect(18);60	isNotFocusable("#formNoTabindex", "form");61	isFocusable("#formTabindex", "form with tabindex");62	isFocusable("#visibleAncestor-inputTypeNone", "input, no type");63	isFocusable("#visibleAncestor-inputTypeText", "input, type text");64	isFocusable("#visibleAncestor-inputTypeCheckbox", "input, type checkbox");65	isFocusable("#visibleAncestor-inputTypeRadio", "input, type radio");66	isFocusable("#visibleAncestor-inputTypeButton", "input, type button");67	isNotFocusable("#visibleAncestor-inputTypeHidden", "input, type hidden");68	isFocusable("#visibleAncestor-button", "button");69	isFocusable("#visibleAncestor-select", "select");70	isFocusable("#visibleAncestor-textarea", "textarea");71	isFocusable("#visibleAncestor-object", "object");72	isFocusable("#visibleAncestor-anchorWithHref", "anchor with href");73	isNotFocusable("#visibleAncestor-anchorWithoutHref", "anchor without href");74	isNotFocusable("#visibleAncestor-span", "span");75	isNotFocusable("#visibleAncestor-div", "div");76	isFocusable("#visibleAncestor-spanWithTabindex", "span with tabindex");77	isFocusable("#visibleAncestor-divWithNegativeTabindex", "div with tabindex");78});79test("focusable - disabled elements", function() {80	expect(9);81	isNotFocusable("#disabledElement-inputTypeNone", "input, no type");82	isNotFocusable("#disabledElement-inputTypeText", "input, type text");83	isNotFocusable("#disabledElement-inputTypeCheckbox", "input, type checkbox");84	isNotFocusable("#disabledElement-inputTypeRadio", "input, type radio");85	isNotFocusable("#disabledElement-inputTypeButton", "input, type button");86	isNotFocusable("#disabledElement-inputTypeHidden", "input, type hidden");87	isNotFocusable("#disabledElement-button", "button");88	isNotFocusable("#disabledElement-select", "select");89	isNotFocusable("#disabledElement-textarea", "textarea");90});91test("focusable - hidden styles", function() {92	expect(8);93	isNotFocusable("#displayNoneAncestor-input", "input, display: none parent");94	isNotFocusable("#displayNoneAncestor-span", "span with tabindex, display: none parent");95	isNotFocusable("#visibilityHiddenAncestor-input", "input, visibility: hidden parent");96	isNotFocusable("#visibilityHiddenAncestor-span", "span with tabindex, visibility: hidden parent");97	isNotFocusable("#displayNone-input", "input, display: none");98	isNotFocusable("#visibilityHidden-input", "input, visibility: hidden");99	isNotFocusable("#displayNone-span", "span with tabindex, display: none");100	isNotFocusable("#visibilityHidden-span", "span with tabindex, visibility: hidden");101});102test("focusable - natively focusable with various tabindex", function() {103	expect(4);104	isFocusable("#inputTabindex0", "input, tabindex 0");105	isFocusable("#inputTabindex10", "input, tabindex 10");106	isFocusable("#inputTabindex-1", "input, tabindex -1");107	isFocusable("#inputTabindex-50", "input, tabindex -50");108});109test("focusable - not natively focusable with various tabindex", function() {110	expect(4);111	isFocusable("#spanTabindex0", "span, tabindex 0");112	isFocusable("#spanTabindex10", "span, tabindex 10");113	isFocusable("#spanTabindex-1", "span, tabindex -1");114	isFocusable("#spanTabindex-50", "span, tabindex -50");115});116test("focusable - area elements", function() {117	expect( 3 );118	isFocusable("#areaCoordsHref", "coords and href");119	isFocusable("#areaNoCoordsHref", "href but no coords");120	isNotFocusable("#areaNoImg", "not associated with an image");121});122test( "focusable - dimensionless parent with overflow", function() {123	expect( 1 );124	isFocusable( "#dimensionlessParent", "input" );125});126test("tabbable - visible, enabled elements", function() {127	expect(18);128	isNotTabbable("#formNoTabindex", "form");129	isTabbable("#formTabindex", "form with tabindex");130	isTabbable("#visibleAncestor-inputTypeNone", "input, no type");131	isTabbable("#visibleAncestor-inputTypeText", "input, type text");132	isTabbable("#visibleAncestor-inputTypeCheckbox", "input, type checkbox");133	isTabbable("#visibleAncestor-inputTypeRadio", "input, type radio");134	isTabbable("#visibleAncestor-inputTypeButton", "input, type button");135	isNotTabbable("#visibleAncestor-inputTypeHidden", "input, type hidden");136	isTabbable("#visibleAncestor-button", "button");137	isTabbable("#visibleAncestor-select", "select");138	isTabbable("#visibleAncestor-textarea", "textarea");139	isTabbable("#visibleAncestor-object", "object");140	isTabbable("#visibleAncestor-anchorWithHref", "anchor with href");141	isNotTabbable("#visibleAncestor-anchorWithoutHref", "anchor without href");142	isNotTabbable("#visibleAncestor-span", "span");143	isNotTabbable("#visibleAncestor-div", "div");144	isTabbable("#visibleAncestor-spanWithTabindex", "span with tabindex");145	isNotTabbable("#visibleAncestor-divWithNegativeTabindex", "div with tabindex");146});147test("tabbable - disabled elements", function() {148	expect(9);149	isNotTabbable("#disabledElement-inputTypeNone", "input, no type");150	isNotTabbable("#disabledElement-inputTypeText", "input, type text");151	isNotTabbable("#disabledElement-inputTypeCheckbox", "input, type checkbox");152	isNotTabbable("#disabledElement-inputTypeRadio", "input, type radio");153	isNotTabbable("#disabledElement-inputTypeButton", "input, type button");154	isNotTabbable("#disabledElement-inputTypeHidden", "input, type hidden");155	isNotTabbable("#disabledElement-button", "button");156	isNotTabbable("#disabledElement-select", "select");157	isNotTabbable("#disabledElement-textarea", "textarea");158});159test("tabbable - hidden styles", function() {160	expect(8);161	isNotTabbable("#displayNoneAncestor-input", "input, display: none parent");162	isNotTabbable("#displayNoneAncestor-span", "span with tabindex, display: none parent");163	isNotTabbable("#visibilityHiddenAncestor-input", "input, visibility: hidden parent");164	isNotTabbable("#visibilityHiddenAncestor-span", "span with tabindex, visibility: hidden parent");165	isNotTabbable("#displayNone-input", "input, display: none");166	isNotTabbable("#visibilityHidden-input", "input, visibility: hidden");167	isNotTabbable("#displayNone-span", "span with tabindex, display: none");168	isNotTabbable("#visibilityHidden-span", "span with tabindex, visibility: hidden");169});170test("tabbable -  natively tabbable with various tabindex", function() {171	expect(4);172	isTabbable("#inputTabindex0", "input, tabindex 0");173	isTabbable("#inputTabindex10", "input, tabindex 10");174	isNotTabbable("#inputTabindex-1", "input, tabindex -1");175	isNotTabbable("#inputTabindex-50", "input, tabindex -50");176});177test("tabbable -  not natively tabbable with various tabindex", function() {178	expect(4);179	isTabbable("#spanTabindex0", "span, tabindex 0");180	isTabbable("#spanTabindex10", "span, tabindex 10");181	isNotTabbable("#spanTabindex-1", "span, tabindex -1");182	isNotTabbable("#spanTabindex-50", "span, tabindex -50");183});184test("tabbable - area elements", function() {185	expect( 3 );186	isTabbable("#areaCoordsHref", "coords and href");187	isTabbable("#areaNoCoordsHref", "href but no coords");188	isNotTabbable("#areaNoImg", "not associated with an image");189});190test( "tabbable - dimensionless parent with overflow", function() {191	expect( 1 );192	isTabbable( "#dimensionlessParent", "input" );193});...

Full Screen

Full Screen

office_strings.debug.js

Source:office_strings.debug.js Github

copy

Full Screen

1Type.registerNamespace('Strings');2Strings.OfficeOM=function Strings_OfficeOM() {3}4Strings.OfficeOM.registerClass('Strings.OfficeOM');5Strings.OfficeOM.L_InvalidNamedItemForBindingType='The specified binding type is not compatible with the supplied named item.';6Strings.OfficeOM.L_EventHandlerNotExist='The specified event type is not supported on this object.';7Strings.OfficeOM.L_UnknownBindingType='The binding type is not supported.';8Strings.OfficeOM.L_InvalidNode='Invalid Node';9Strings.OfficeOM.L_NotImplemented='Function {0} is not implemented.';10Strings.OfficeOM.L_NoCapability='You don\'t have sufficient permissions for this action.';11Strings.OfficeOM.L_SettingsCannotSave='The settings could not be saved.';12Strings.OfficeOM.L_InvalidBinding='Invalid Binding';13Strings.OfficeOM.L_BindingCreationError='Binding Creation Error';14Strings.OfficeOM.L_SelectionNotSupportCoercionType='The current selection is not compatible with the specified coercion type.';15Strings.OfficeOM.L_InvalidBindingError='Invalid Binding Error';16Strings.OfficeOM.L_InvalidGetStartRowColumn='The specified startRow or startColumn values are invalid.';17Strings.OfficeOM.L_CannotWriteToSelection='Cannot write to the current selection.';18Strings.OfficeOM.L_IndexOutOfRange='Index out of range.';19Strings.OfficeOM.L_SettingsStaleError='Settings Stale Error';20Strings.OfficeOM.L_ReadSettingsError='Read Settings Error';21Strings.OfficeOM.L_CoercionTypeNotSupported='The specified coercion type is not supported.';22Strings.OfficeOM.L_AppNotExistInitializeNotCalled='Application {0} does not exist. Microsoft.Office.WebExtension.initialize(reason) is not called.';23Strings.OfficeOM.L_OverwriteWorksheetData='The set operation failed because the supplied data object will overwrite or shift data.';24Strings.OfficeOM.L_UnsupportedEnumeration='Unsupported Enumeration';25Strings.OfficeOM.L_InvalidParameters='Function {0} has invalid parameters.';26Strings.OfficeOM.L_DataNotMatchCoercionType='The type of the specified data object is not compatible with the current selection.';27Strings.OfficeOM.L_UnsupportedEnumerationMessage='The enumeration isn\'t supported in the current host application.';28Strings.OfficeOM.L_InvalidCoercion='Invalid Coercion Type';29Strings.OfficeOM.L_NotSupportedEventType='The specified event type {0} is not supported.';30Strings.OfficeOM.L_UnsupportedDataObject='The supplied data object type is not supported.';31Strings.OfficeOM.L_GetDataIsTooLarge='The requested data set is too large.';32Strings.OfficeOM.L_AppNameNotExist='AppName for {0} doesn\'t exist.';33Strings.OfficeOM.L_AddBindingFromPromptDefaultText='Please make a selection.';34Strings.OfficeOM.L_MultipleNamedItemFound='Multiple objects with the same name were found.';35Strings.OfficeOM.L_DataNotMatchBindingType='The specified data object is not compatible with the binding type.';36Strings.OfficeOM.L_NotSupportedBindingType='The specified binding type {0} is not supported.';37Strings.OfficeOM.L_InitializeNotReady='Office.js has not been fully loaded yet. Please try again later or make sure to add your initialization code on the Office.initialize function.';38Strings.OfficeOM.L_ShuttingDown='Operation failed because the data is not current on the server.';39Strings.OfficeOM.L_OperationNotSupported='The operation is not supported.';40Strings.OfficeOM.L_DocumentReadOnly='The requested operation is not allowed on the current document mode.';41Strings.OfficeOM.L_NamedItemNotFound='The named item does not exist.';42Strings.OfficeOM.L_InvalidApiCallInContext='Invalid API call in the current context.';43Strings.OfficeOM.L_SetDataIsTooLarge='The specified data object is too large.';44Strings.OfficeOM.L_DataWriteError='Data Write Error';45Strings.OfficeOM.L_InvalidBindingOperation='Invalid Binding Operation';46Strings.OfficeOM.L_FunctionCallFailed='Function {0} call failed, error code: {1}.';47Strings.OfficeOM.L_DataNotMatchBindingSize='The supplied data object does not match the size of the current selection.';48Strings.OfficeOM.L_SaveSettingsError='Save Settings Error';49Strings.OfficeOM.L_InvalidSetStartRowColumn='The specified startRow or startColumn values are invalid.';50Strings.OfficeOM.L_InvalidFormat='Invalid Format Error';51Strings.OfficeOM.L_BindingNotExist='The specified binding does not exist.';52Strings.OfficeOM.L_EventHandlerAdditionFailed='Failed to add the event handler.';53Strings.OfficeOM.L_SettingNameNotExist='The specified setting name does not exist.';54Strings.OfficeOM.L_InvalidAPICall='Invalid API Call';55Strings.OfficeOM.L_EventRegistrationError='Event Registration Error';56Strings.OfficeOM.L_NonUniformPartialSetNotSupported='Coordinate parameters cannot be used with coercion type Table when the table contains merged cells.';57Strings.OfficeOM.L_RedundantCallbackSpecification='Callback cannot be specified both in argument list and in optional object.';58Strings.OfficeOM.L_CustomXmlError='Custom XML Error.';59Strings.OfficeOM.L_SettingsAreStale='Settings could not be saved because they are not current.';60Strings.OfficeOM.L_TooManyOptionalFunction='multiple optional functions in parameter list';61Strings.OfficeOM.L_MissingRequiredArguments='missing some required arguments';62Strings.OfficeOM.L_NonUniformPartialGetNotSupported='Coordinate parameters cannot be used with coercion type Table when the table contains merged cells.';63Strings.OfficeOM.L_HostError='Host Error';64Strings.OfficeOM.L_InvalidSelectionForBindingType='A binding cannot be created with the current selection and the specified binding type.';65Strings.OfficeOM.L_TooManyOptionalObjects='multiple optional objects in parameter list';66Strings.OfficeOM.L_EventHandlerRemovalFailed='Failed to remove the event handler.';67Strings.OfficeOM.L_BindingToMultipleSelection='Noncontiguous selections are not supported.';68Strings.OfficeOM.L_DataReadError='Data Read Error';69Strings.OfficeOM.L_InternalErrorDescription='An internal error has occurred.';70Strings.OfficeOM.L_InvalidDataFormat='The format of the specified data object is invalid.';71Strings.OfficeOM.L_DataStale='Data Not Current';72Strings.OfficeOM.L_GetSelectionNotSupported='The current selection is not supported.';73Strings.OfficeOM.L_PermissionDenied='Permission Denied';74Strings.OfficeOM.L_InvalidDataObject='Invalid Data Object';75Strings.OfficeOM.L_SelectionCannotBound='Cannot bind to the current selection.';76Strings.OfficeOM.L_BadSelectorString='The string passed into the selector is improperly formatted or unsupported.';77Strings.OfficeOM.L_InvalidGetRowColumnCounts='The specified rowCount or columnCount values are invalid.';78Strings.OfficeOM.L_OsfControlTypeNotSupported='OsfControl type not supported.';79Strings.OfficeOM.L_DataNotMatchSelection='The supplied data object is not compatible with the shape or dimensions of the current selection.';80Strings.OfficeOM.L_InternalError='Internal Error';81Strings.OfficeOM.L_NotSupported='Function {0} is not supported.';82Strings.OfficeOM.L_CustomXmlNodeNotFound='The specified node was not found.';83Strings.OfficeOM.L_CoercionTypeNotMatchBinding='The specified coercion type is not compatible with this binding type.';84Strings.OfficeOM.L_TooManyArguments='too many arguments';85Strings.OfficeOM.L_OperationNotSupportedOnThisBindingType='Operation is not supported on this binding type.';86Strings.OfficeOM.L_InValidOptionalArgument='invalid optional argument';87Strings.OfficeOM.L_FileTypeNotSupported='The specified file type is not supported.';...

Full Screen

Full Screen

space.test.js

Source:space.test.js Github

copy

Full Screen

...19  const { utilities } = invokePlugin(plugin(), config)20  expect(utilities).toEqual([21    [22      {23        '.space-y-0 > :not([hidden]) ~ :not([hidden])': {24          '--tw-space-y-reverse': '0',25          'margin-top': 'calc(0px * calc(1 - var(--tw-space-y-reverse)))',26          'margin-bottom': 'calc(0px * var(--tw-space-y-reverse))',27        },28        '.space-x-0 > :not([hidden]) ~ :not([hidden])': {29          '--tw-space-x-reverse': '0',30          'margin-right': 'calc(0px * var(--tw-space-x-reverse))',31          'margin-left': 'calc(0px * calc(1 - var(--tw-space-x-reverse)))',32        },33        '.space-y-1 > :not([hidden]) ~ :not([hidden])': {34          '--tw-space-y-reverse': '0',35          'margin-top': 'calc(1px * calc(1 - var(--tw-space-y-reverse)))',36          'margin-bottom': 'calc(1px * var(--tw-space-y-reverse))',37        },38        '.space-x-1 > :not([hidden]) ~ :not([hidden])': {39          '--tw-space-x-reverse': '0',40          'margin-right': 'calc(1px * var(--tw-space-x-reverse))',41          'margin-left': 'calc(1px * calc(1 - var(--tw-space-x-reverse)))',42        },43        '.space-y-2 > :not([hidden]) ~ :not([hidden])': {44          '--tw-space-y-reverse': '0',45          'margin-top': 'calc(2px * calc(1 - var(--tw-space-y-reverse)))',46          'margin-bottom': 'calc(2px * var(--tw-space-y-reverse))',47        },48        '.space-x-2 > :not([hidden]) ~ :not([hidden])': {49          '--tw-space-x-reverse': '0',50          'margin-right': 'calc(2px * var(--tw-space-x-reverse))',51          'margin-left': 'calc(2px * calc(1 - var(--tw-space-x-reverse)))',52        },53        '.space-y-4 > :not([hidden]) ~ :not([hidden])': {54          '--tw-space-y-reverse': '0',55          'margin-top': 'calc(4px * calc(1 - var(--tw-space-y-reverse)))',56          'margin-bottom': 'calc(4px * var(--tw-space-y-reverse))',57        },58        '.space-x-4 > :not([hidden]) ~ :not([hidden])': {59          '--tw-space-x-reverse': '0',60          'margin-right': 'calc(4px * var(--tw-space-x-reverse))',61          'margin-left': 'calc(4px * calc(1 - var(--tw-space-x-reverse)))',62        },63        '.-space-y-2 > :not([hidden]) ~ :not([hidden])': {64          '--tw-space-y-reverse': '0',65          'margin-top': 'calc(-2px * calc(1 - var(--tw-space-y-reverse)))',66          'margin-bottom': 'calc(-2px * var(--tw-space-y-reverse))',67        },68        '.-space-x-2 > :not([hidden]) ~ :not([hidden])': {69          '--tw-space-x-reverse': '0',70          'margin-right': 'calc(-2px * var(--tw-space-x-reverse))',71          'margin-left': 'calc(-2px * calc(1 - var(--tw-space-x-reverse)))',72        },73        '.-space-y-1 > :not([hidden]) ~ :not([hidden])': {74          '--tw-space-y-reverse': '0',75          'margin-top': 'calc(-1px * calc(1 - var(--tw-space-y-reverse)))',76          'margin-bottom': 'calc(-1px * var(--tw-space-y-reverse))',77        },78        '.-space-x-1 > :not([hidden]) ~ :not([hidden])': {79          '--tw-space-x-reverse': '0',80          'margin-right': 'calc(-1px * var(--tw-space-x-reverse))',81          'margin-left': 'calc(-1px * calc(1 - var(--tw-space-x-reverse)))',82        },83        '.space-y-reverse > :not([hidden]) ~ :not([hidden])': {84          '--tw-space-y-reverse': '1',85        },86        '.space-x-reverse > :not([hidden]) ~ :not([hidden])': {87          '--tw-space-x-reverse': '1',88        },89      },90      ['responsive'],91    ],92  ])...

Full Screen

Full Screen

journals.js

Source:journals.js Github

copy

Full Screen

2const { validateResult } = require('../helpers/validateHelper')3const validateCreateJournal = [4  check('author')5    .exists()6    .not()7    .isEmpty(),8  check('title')9    .exists()10    .not()11    .isEmpty(),12  check('edition')13    .exists()14    .not()15    .isEmpty(),16  check('description')17    .exists()18    .not()19    .isEmpty(),20  check('currentFrequency')21    .exists()22    .not()23    .isEmpty(),24  check('specimens')25    .exists()26    .not()27    .isEmpty(),28  check('theme')29    .exists()30    .not()31    .isEmpty(),32  check('keyword')33    .exists()34    .not()35    .isEmpty(),36  check('copy')37    .exists()38    .not()39    .isEmpty(),40  check('available')41    .exists()42    .not()43    .isEmpty(),44  (req, res, next) => {45    validateResult(req, res, next)46  }47]48const validateUpdateJournal = [49  check('author')50    .exists()51    .not()52    .isEmpty(),53  check('title')54    .exists()55    .not()56    .isEmpty(),57  check('edition')58    .exists()59    .not()60    .isEmpty(),61  check('description')62    .exists()63    .not()64    .isEmpty(),65  check('currentFrequency')66    .exists()67    .not()68    .isEmpty(),69  check('specimens')70    .exists()71    .not()72    .isEmpty(),73  check('theme')74    .exists()75    .not()76    .isEmpty(),77  check('keyword')78    .exists()79    .not()80    .isEmpty(),81  check('copy')82    .exists()83    .not()84    .isEmpty(),85  check('available')86    .exists()87    .not()88    .isEmpty(),89  check('id')90    .exists()91    .withMessage('MISSING')92    .not()93    .isEmpty()94    .withMessage('IS_EMPTY'),95  (req, res, next) => {96    validateResult(req, res, next)97  }98]99/**100 * Validates get item request101 */102const validateGetJournal = [103  check('id')104    .exists()105    .withMessage('MISSING')106    .not()107    .isEmpty()108    .withMessage('IS_EMPTY'),109  (req, res, next) => {110    validateResult(req, res, next)111  }112]113module.exports = {114  validateCreateJournal,115  validateGetJournal,116  validateUpdateJournal...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('not', { prevSubject: 'element' }, ($el) => {2  return cy.wrap($el).should('not.exist')3})4Cypress.Commands.add('not', { prevSubject: 'element' }, ($el) => {5  return cy.wrap($el).should('not.exist')6})7Cypress.Commands.add('not', { prevSubject: 'element' }, ($el) => {8  return cy.wrap($el).should('not.exist')9})10Cypress.Commands.add('not', { prevSubject: 'element' }, ($el) => {11  return cy.wrap($el).should('not.exist')12})13Cypress.Commands.add('not', { prevSubject: 'element' }, ($el) => {14  return cy.wrap($el).should('not.exist')15})16Cypress.Commands.add('not', { prevSubject: 'element' }, ($el) => {17  return cy.wrap($el).should('not.exist')18})19Cypress.Commands.add('not', { prevSubject: 'element' }, ($el) => {20  return cy.wrap($el).should('not.exist')21})22Cypress.Commands.add('not', { prevSubject: 'element' }, ($el) => {23  return cy.wrap($el).should('not.exist')24})25Cypress.Commands.add('not', { prevSubject: 'element' }, ($el) => {26  return cy.wrap($el).should('not.exist')27})28Cypress.Commands.add('not', { prevSubject: 'element' }, ($el) => {29  return cy.wrap($el).should('not.exist')30})31Cypress.Commands.add('not', { prevSubject: 'element' }, ($el) => {32  return cy.wrap($el).should('not.exist')33})34Cypress.Commands.add('not', { prevSubject: 'element' }, ($el) => {35  return cy.wrap($el).should('not.exist')36})

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('not', { prevSubject: 'element' }, (subject, selector) => {2  return cy.wrap(subject).should('not.have.descendants', selector)3})4Cypress.Commands.add('not', { prevSubject: 'element' }, (subject, selector) => {5  return cy.wrap(subject).should('not.have.descendants', selector)6})7Cypress.Commands.add('not', { prevSubject: 'element' }, (subject, selector) => {8  return cy.wrap(subject).should('not.have.descendants', selector)9})10Cypress.Commands.add('not', { prevSubject: 'element' }, (subject, selector) => {11  return cy.wrap(subject).should('not.have.descendants', selector)12})13Cypress.Commands.add('not', { prevSubject: 'element' }, (subject, selector) => {14  return cy.wrap(subject).should('not.have.descendants', selector)15})16Cypress.Commands.add('not', { prevSubject: 'element' }, (subject, selector) => {17  return cy.wrap(subject).should('not.have.descendants', selector)18})19Cypress.Commands.add('not', { prevSubject: 'element' }, (subject, selector) => {20  return cy.wrap(subject).should('not.have.descendants', selector)21})22Cypress.Commands.add('not', { prevSubject: 'element' }, (subject, selector) => {23  return cy.wrap(subject).should('not.have.descendants', selector)24})25Cypress.Commands.add('not', { prevSubject: 'element' }, (subject, selector) => {26  return cy.wrap(subject).should('not.have.descendants', selector)27})28Cypress.Commands.add('not', { prevSubject: 'element' }, (subject, selector) => {

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('not', { prevSubject: 'element' }, (subject, selector) => {2  cy.wrap(subject).should('not.have.descendants', selector)3})4Cypress.Commands.add('shouldHaveAttribute', { prevSubject: 'element' }, (subject, attribute, value) => {5  cy.wrap(subject).should('have.attr', attribute, value)6})7Cypress.Commands.add('shouldHaveId', { prevSubject: 'element' }, (subject, id) => {8  cy.wrap(subject).should('have.attr', 'id', id)9})10Cypress.Commands.add('shouldHaveClass', { prevSubject: 'element' }, (subject, className) => {11  cy.wrap(subject).should('have.class', className)12})13Cypress.Commands.add('shouldHaveText', { prevSubject: 'element' }, (subject, text) => {14  cy.wrap(subject).should('have.text', text)15})16Cypress.Commands.add('shouldHaveValue', { prevSubject: 'element' }, (subject, value) => {17  cy.wrap(subject).should('have.value', value)18})19Cypress.Commands.add('shouldHaveText', { prevSubject: 'element' }, (subject, text) => {20  cy.wrap(subject).should('have.text', text)21})22Cypress.Commands.add('shouldHaveText', { prevSubject: 'element' }, (subject, text) => {23  cy.wrap(subject).should('have.text', text)24})25Cypress.Commands.add('shouldHaveText', { prevSubject: 'element' }, (subject, text) => {26  cy.wrap(subject).should('have.text', text)27})28Cypress.Commands.add('shouldHaveText', { prevSubject: 'element' }, (subject, text) => {29  cy.wrap(subject).should('have.text', text)30})31Cypress.Commands.add('shouldHaveText', { prevSubject

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('not', { prevSubject: true }, (subject, selector) => {2    return cy.wrap(subject).should('not.have.descendants', selector)3  })4describe('Test', () => {5    it('Test', () => {6        cy.get('#hplogo').not('div')7    })8})

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('not', { prevSubject: true }, (subject) => {2  expect(subject).to.be.false3})4it('test case', () => {5  cy.get('input[type="checkbox"]').check()6  cy.get('input[type="checkbox"]').not().should('not.be.checked')7})8it('test case', () => {9  cy.get('input[type="checkbox"]').check()10  cy.get('input[type="checkbox"]').not().should('be.checked')11})12Cypress.Commands.add('login', () => {13  cy.get('#email1').type('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2  it('Does not do much!', function() {3    expect(true).to.not.equal(false)4  })5})6describe('My First Test', function() {7  it('Does not do much!', function() {8    expect(true).to.equal(true).and.to.not.equal(false)9  })10})11describe('My First Test', function() {12  it('Does not do much!', function() {13    expect(true).to.equal(true).or.to.not.equal(false)14  })15})16describe('My First Test', function() {17  it('Does not do much!', function() {18    expect(true).to.be.a('boolean')19  })20})21describe('My First Test', function() {22  it('Does not do much!', function() {23    expect(true).to.equal(true)24  })25})26describe('My First Test', function() {27  it('Does not do much!', function() {28    expect([1,2,3]).to.have.length(3)29  })30})31describe('My First Test', function() {32  it('Does not do much!', function() {33    expect([

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('not', { prevSubject: true }, (subject, options) => {2  cy.wrap(subject, options).should('not.exist')3})4it('should not see the element', () => {5  cy.get('#element').not()6})7it('should not see the element', () => {8  cy.get('#element').should('not.exist')9})10it('should not see the element', () => {11  cy.get('#element').should('not.be.visible')12})13Using Cypress.Commands.add() method14Using Cypress.Commands.overwrite() method15In the above example, we have used Cypress.Commands.add() method. You can also use Cypress.Commands.overwrite() method to overwrite the existing Cypress commands. You can find more about it here

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.get('#element').should('not.exist')2cy.get('#element').should('not.be.visible')3cy.get('#element').should(($element) => {4    expect($element).not.to.exist5    expect($element).not.to.be.visible6})7cy.get('#element').should(($element) => {8    expect($element).to.not.exist9    expect($element).to.not.be.visible10})11cy.get('#element').should(($element) => {12    expect($element).to.not.exist13    expect($element).to.not.be.visible14})15cy.get('#element').should(($element) => {16    expect($element).to.not.exist17    expect($element).to.not.be.visible18})19cy.get('#element').should(($element) => {20    expect($element).to.not.exist21    expect($element).to.not.be.visible22})23cy.get('#element').should(($element) => {24    expect($element).to.not.exist25    expect($element).to.not.be.visible26})

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful