Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* 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', () => {
/* 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() {
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 => {
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 => {
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;
const run = require('./run');
const pathModule = require('path');
const expect = require('unexpected').clone();
expect.addAssertion(
' to yield output ',
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}`
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;
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();
});
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);
});
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(' to be an error named ', 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');