How to use the assert function in assert

To help you get started, we’ve selected a few assert examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bonham000 / fcc-react-tests-module / src / challenges / redux / Redux_08.js View on Github external
typeof reduxCode !== 'undefined' &&
      code.toString().includes('switch') &&
      code.toString().includes('case') &&
      code.toString().includes('default'),
      error_6);
    testResults[6].status = true;
  } catch (err) {
    passed = false;
    testResults[6].status = false;
  }

  const noWhiteSpace = code.toString().replace(/\s/g,'');

  // test 7:
  try {
    assert(
      (noWhiteSpace.includes('constLOGIN=\'LOGIN\'') || noWhiteSpace.includes('constLOGIN="LOGIN"')) &&
      (noWhiteSpace.includes('constLOGOUT=\'LOGOUT\'') || noWhiteSpace.includes('constLOGOUT="LOGOUT"')),
      error_7);
    testResults[7].status = true;
  } catch (err) {
    passed = false;
    testResults[7].status = false;
  }

  // test 8:
  try {
    assert(
      noWhiteSpace.includes('caseLOGIN:') &&
      noWhiteSpace.includes('caseLOGOUT:') &&
      noWhiteSpace.includes('type:LOGIN') &&
      noWhiteSpace.includes('type:LOGOUT'),
github martinandert / babel-plugin-css-in-js / src / transformStyleSheetObjectIntoSpecification.js View on Github external
foreach(content, (value, key) => {
    if (isMediaQueryDeclaration.test(key)) {
      processMediaQuery(styles, key.substring(1), value, parent);
    } else if (isStandaloneSelector.test(key)) {
      assert(false, 'stand-alone selectors are not allowed at the top-level');
    } else if (hasAttachedSelector.test(key)) {
      const [styleName, selectorName] = splitSelector(key);
      processStyleAndSelector(styles, styleName, selectorName, value, parent);
    } else if (key.charAt(0) === '$') {
      const firstSubKey = Object.keys(value)[0];

      if (!isPlainObject(value[firstSubKey])) {
        // needs to be deprecated
        processStyle(styles, key, value);
      } else {
        transformStyleSheetObjectIntoSpecification(value, styles, key.substring(1));
      }
    } else {
      processStyle(styles, key, value, parent);
    }
  });
github bitshares / bitsharesjs / test / serializer / all_types.js View on Github external
it("to object", function() {
            assert(toObject(allTypes), "serializable");
            assert.deepEqual(
                toObject(allTypes),
                toObject(allTypes),
                "serializable (single to)"
            );
            assert.deepEqual(
                toObject(toObject(allTypes)),
                toObject(allTypes),
                "serializable (double to)"
            );
            assert.deepEqual(
                toObject(fromObject(allTypes)),
                toObject(allTypes),
                "non-serializable"
            );
            assert.deepEqual(
github dankuck / vue-easeljs / test / EaselCanvas.spec.js View on Github external
let firstCreateCanvas,
            secondCreateCanvas,
            firstCreateCanvasAgain;
        canvas.createCanvas(() => {
            firstCreateCanvas = easeljs.createCanvas;
            canvas.createCanvas(() => {
                secondCreateCanvas = easeljs.createCanvas;
            });
            firstCreateCanvasAgain = easeljs.createCanvas;
        });
        assert(firstCreateCanvas, 'firstCreateCanvas should exist');
        assert(secondCreateCanvas, 'secondCreateCanvas should exist');
        assert(firstCreateCanvasAgain, 'firstCreateCanvasAgain should exist');
        assert(secondCreateCanvas !== firstCreateCanvas, '1st and 2nd should not be the same');
        assert(firstCreateCanvas === firstCreateCanvasAgain, '1st and 3rd should be the same');
        assert(!easeljs.createCanvas, 'createCanvas should not exist');
    });
github alixander / Stanchion / test / unit-test / index.spec.js View on Github external
}).then(() => {
        assert(dispatchRequest.calledWith(19));
        assert(dispatchRequest.neverCalledWith(6));
      });
    });
github facebookarchive / atom-ide-ui / modules / atom-ide-ui / pkg / atom-ide-diagnostics / spec / MessageRangeTracker-spec.js View on Github external
it('should return ranges for already-open files', () => {
    tracker.addFileMessages([messageForInitiallyOpenFile]);
    const range = tracker.getCurrentRange(messageForInitiallyOpenFile);
    invariant(range != null);
    expect(range.isEqual(new Range([1, 18], [1, 22]))).toBeTruthy();
    checkRep(tracker);
  });
github heineiuo / rippledb / src / SSTableBuilder.ts View on Github external
async flush(): Promise {
    assert(!this._closed)
    if (this._dataBlock.isEmpty()) return
    assert(!this._pendingIndexEntry)
    await this.writeBlock(this._dataBlock, this._pendingHandle)
    this._pendingIndexEntry = true
    if (!!this._metaBlock) {
      this._metaBlock.startBlock(this._offset)
    }
  }
github facebookarchive / flow-language-server / server / src / pkg / nuclide-logging / lib / main.js View on Github external
function setLoggerLevelHelper(level: string): void {
    const logger = getLog4jsLogger(category);
    invariant(logger);
    logger.setLevel(level);
  }
github jmlweb / ramdu / src / __spec__ / index.spec.js View on Github external
describe('Main file', () => {
  assert(RU);
});
github JoinColony / colonyJS / packages / colony-js-utils / src / makeAssert.js View on Github external
return (assertion: boolean, reason: string) => {
    assert(assertion, `${message}: ${reason}`);
    return true;
  };
}