View 0_test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable no-console */ | |
/* eslint-disable prefer-arrow-callback */ | |
import expect from 'expect'; | |
import { createTestClient } from 'apollo-server-testing'; | |
import ggl from 'graphql-tag'; | |
import config from '../../../config'; | |
import { createServer } from '../../../src/server'; |
View invoice-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('GET /v2/invoices/{id}.html specs', function () { | |
describe('de', function () { | |
before(function () { | |
// call API and store response.. | |
}); | |
it('should return correct html', function () { | |
expect(beautify(this.response.payload)).toMatchSnapshot(this); | |
}); | |
}); |
View makeTestTitle.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const makeTestTitle = test => { | |
let next = test; | |
const title = []; | |
for (;;) { | |
if (!next.parent) { | |
break; | |
} | |
title.push(next.title); |
View expect-toMatchSnapshot-2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expect.extend({ | |
toMatchSnapshot(ctx) { | |
if (!ctx || !ctx.test) { | |
throw new Error( | |
dedent(`missing \`ctx\` parameter for .toMatchSnapshot(), | |
did you forget to pass \`this\` expect().toMatchSnapshot(this)?`), | |
); | |
} | |
const { test } = ctx; |
View expect-toMatchSnapshot.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expect.extend({ | |
toMatchSnapshot() { | |
// TODO: init testFile, testTitle | |
const result = toMatchSnapshot(this.actual, testFile, testTitle); | |
expect.assert(result.pass, !result.pass ? result.report() : ''); | |
return this; | |
} |
View toMatchSnapshot.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { SnapshotState, toMatchSnapshot } from ‘jest-snapshot’; | |
export function toMatchSnapshot(actual, testFile, testTitle) { | |
// Intilize the SnapshotState, it’s responsible for actually matching | |
// actual snapshot with expected one and storing results to `__snapshots__` folder | |
const snapshotState = new SnapshotState(testFile, { | |
updateSnapshot: process.env.SNAPSHOT_UPDATE ? ‘all’ : ‘new’, | |
}); | |
// Bind the `toMatchSnapshot` to the object with snapshotState and |
View expect-2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expect(response).toMatchSnapshot(); |
View expect.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expect(response.data.headline).toEqual(‘Document #12–1332–11’); | |
expect(response.data.address.city).toEqual(‘Berlin’); | |
expect(response.data[0].line[0].total).toEqual(101); | |
expect(response.data[0].line[1].total).toEqual(102); | |
expect(response.data[0].line[2].total).toEqual(103); | |
expect(response.data[0].line[3].total).toEqual(104); | |
expect(response.data[1].line[0].total).toEqual(105); | |
expect(response.data[1].line[1].total).toEqual(106); | |
expect(response.data[1].line[2].total).toEqual(107); | |
expect(response.data[1].line[3].total).toEqual(108); |
View get_invoices_html.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint prefer-arrow-callback: 0 */ | |
import expect from 'expect'; | |
import moment from 'moment'; | |
import timekeeper from 'timekeeper'; | |
import beautify from 'js-beautify'; | |
import * as apiUtils from '../../../helpers/api'; | |
import * as serverUtils from '../../../helpers/server'; | |
import * as mongoUtils from '../../../helpers/mongo'; |
View trackable.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function trackable(action, event, properties = {}) { | |
const analytics = { | |
eventType: event, | |
eventPayload: properties | |
}; | |
return { ...action, meta: { analytics } }; | |
} |
NewerOlder