How to use the unexpected.clone function in unexpected

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

github FreeFeed / freefeed-server / test / unit / support / BestOfDigest.js View on Github external
/* eslint-env node, mocha */
import unexpected from 'unexpected';
import unexpectedMoment from 'unexpected-moment';
import moment from 'moment';

import { shouldSendDailyBestOfDigest, shouldSendWeeklyBestOfDigest, canMakeBestOfEmail } from '../../../app/support/BestOfDigest';


const expect = unexpected.clone()
  .use(unexpectedMoment);

describe('BestOfDigest', () => {
  describe('shouldSendDailyBestOfDigest()', () => {
    const someTimeAgo = '2017-12-28T00:00:00.000Z';
    const now = '2018-01-01T00:00:00.000Z';

    describe('if weekly digest has never been sent previously', () => {
      describe('if daily digest has never been sent previously', () => {
        it('should send daily summary email', async () => {
          await expect(shouldSendDailyBestOfDigest(null, undefined, now), 'to be', true);
          await expect(shouldSendDailyBestOfDigest(undefined, undefined, now), 'to be', true);
        });
      });

      describe('if sent several days ago', () => {
github Munter / subfont / test / subfont.js View on Github external
/* global describe, it */
const sinon = require('sinon');
const expect = require('unexpected')
  .clone()
  .use(require('unexpected-sinon'));
const subfont = require('../lib/subfont');
const httpception = require('httpception');
const proxyquire = require('proxyquire');
const pathModule = require('path');
const openSansBold = require('fs').readFileSync(
  pathModule.resolve(
    __dirname,
    '..',
    'testdata',
    'k3k702ZOKiLJc3WVjuplzHhCUOGz7vYGh680lGh-uXM.woff'
  )
);

describe('subfont', function() {
github papandreou / node-optipng / test / OptiPng.js View on Github external
const expect = require('unexpected')
  .clone()
  .use(require('unexpected-stream'))
  .use(require('unexpected-sinon'));
const sinon = require('sinon');
const OptiPng = require('../lib/OptiPng');
const Path = require('path');
const fs = require('fs');

describe('OptiPng', () => {
  it('should produce a smaller file when run with -o7 on a suboptimal PNG', () =>
    expect(
      fs.createReadStream(Path.resolve(__dirname, 'suboptimal.png')),
      'when piped through',
      new OptiPng(['-o7']),
      'to yield output satisfying',
      expect.it(resultPngBuffer => {
github papandreou / node-pngcrush / test / PngCrush.js View on Github external
const expect = require('unexpected')
  .clone()
  .use(require('unexpected-stream'))
  .use(require('unexpected-sinon'));
const PngCrush = require('../lib/PngCrush');
const sinon = require('sinon');
const pathModule = require('path');
const fs = require('fs');

describe('PngCrush', () => {
  it('should produce a smaller file when run with -rem alla on a PNG with ancillary chunks', () =>
    expect(
      fs.createReadStream(pathModule.resolve(__dirname, 'ancillaryChunks.png')),
      'when piped through',
      new PngCrush(['-rem', 'alla']),
      'to yield output satisfying',
      expect.it(resultPngBuffer => {
github One-com / knockout-transformations / test / indexBy.spec.js View on Github external
var ko = require('knockout');
var expect = require('unexpected').clone()
    .installPlugin(require('unexpected-sinon'))
    .installPlugin(require('unexpected-knockout'));
var sinon = require('sinon');

require('../lib/indexBy.js');

function Person(name, yearOfBirth) {
    this.name = ko.observable(name);
    this.yearOfBirth = ko.observable(yearOfBirth);
}

expect.addType({
    name: 'Person',
    base: 'object',
    identify: function (value) {
        return value instanceof Person;
github papandreou / seespee / test / cli.js View on Github external
const run = require('./run');
const pathModule = require('path');
const expect = require('unexpected').clone();

expect.addAssertion(
  '<array> to yield output <string>',
  async (expect, args, expectedOutput) => {
    expect.errorMode = 'nested';
    let stdout;
    let stderr;
    try {
      [stdout, stderr] = await run([
        pathModule.resolve(__dirname, '..', 'lib', 'cli.js'),
        ...args
      ]);
    } catch (err) {
      if (err.stderr) {
        expect.fail(
          `Child process exited with ${err.code} and stderr ${err.stderr}`
github knorm / knorm / test / Field.spec.js View on Github external
const uuid = require('uuid');
const Knorm = require('../lib/Knorm');
const sinon = require('sinon');
const expect = require('unexpected')
  .clone()
  .use(require('unexpected-sinon'))
  .use(require('./lib/unexpected-workaround'));

describe('Field', function() {
  let Model;
  let Query;
  let Field;
  let sql;

  before(function() {
    const orm = new Knorm();
    Model = orm.Model;
    Query = orm.Query;
    Field = orm.Field;
    sql = Query.prototype.sql;
github One-com / knockout-transformations / test / filter.spec.js View on Github external
var ko = require('knockout');
var expect = require('unexpected').clone()
    .installPlugin(require('unexpected-sinon'));
var sinon = require('sinon');

require('../lib/filter.js');

describe("Filter", function () {
    var clock;

    beforeEach(function () {
        clock = sinon.useFakeTimers();
    });

    afterEach(function () {
        clock.restore();
    });
github knorm / knorm / test / Sql / Desc.spec.js View on Github external
const expect = require('unexpected').clone();
const createUser = require('./lib/createUser');
const Dummy = require('./lib/Dummy');
const Desc = require('../../lib/Sql/Desc');

describe('Sql/Desc', () => {
  let User;

  before(() => {
    User = createUser();
  });

  let desc;

  beforeEach(() => {
    desc = new Desc(User);
  });
github knorm / knorm / test / DbModel.spec.js View on Github external
const Query = require('../../../lib/newModels/Query');
const DbModel = require('../../../lib/newModels/DbModel');
const Field = require('../../../lib/newModels/Field');
const knex = require('../../../lib/services/knex')();
const sinon = require('sinon');
const expect = require('unexpected')
    .clone()
    .use(require('unexpected-sinon'))
    .use(require('../../unexpected-sorted-array'))
    .addAssertion('<function> to be an error named <string>', function (expect, CustomError, name) {
        const error = new CustomError();
        return expect(error, 'to satisfy', {
            name,
            [name]: true,
        });
    });

const createUserTable = table => {
    table.increments();
    table.timestamps();
    table.string('name').notNullable();
    table.text('description');

unexpected

Extensible BDD assertion toolkit

MIT
Latest version published 1 month ago

Package Health Score

81 / 100
Full package analysis

Similar packages