How to use fakeServer method in pact-foundation-pact

Best JavaScript code snippet using pact-foundation-pact

fake_server_spec.js

Source:fake_server_spec.js Github

copy

Full Screen

1//= require monarch_spec_helper2Screw.Unit(function(c) { with(c) {3 describe("Monarch.Http.FakeServer", function() {4 useExampleDomainModel();5 var fakeServer;6 before(function() {7 Repository.sandboxUrl = "/users/bob/sandbox"8 fakeServer = new Monarch.Http.FakeServer(false);9 fakeServer.Repository.loadFixtures({10 users: {11 sharon: {12 fullName: "Sharon Ly"13 },14 stephanie: {15 fullName: "Stephanie Wambach"16 }17 },18 blogs: {19 guns: {20 name: "Guns, Ammo, and Me",21 userId: "sharon"22 },23 aircraft: {24 name: "My Favorite Aircraft",25 userId: "stephanie"26 }27 }28 });29 });30 describe("#fetch", function() {31 it("adds a FakeFetch to a #fetches array, then executes the fetch against its fixture repository and triggers the returned future when #simulateSuccess is called on it", function() {32 var beforeEventsCallback = mockFunction("before delta events callback", function() {33 expect(User.find("sharon")).toNot(beNull);34 expect(insertCallback).toNot(haveBeenCalled);35 });36 var insertCallback = mockFunction("on insert callback");37 var afterEventsCallback = mockFunction("after delta events callback", function() {38 expect(User.find("sharon")).toNot(beNull);39 expect(insertCallback).to(haveBeenCalled, twice);40 });41 User.onInsert(insertCallback);42 expect(fakeServer.fetches).to(beEmpty);43 expect(User.find('sharon')).to(beNull);44 expect(Blog.find('guns')).to(beNull);45 var future = fakeServer.fetch(Blog.table, User.table);46 future.beforeEvents(beforeEventsCallback);47 future.afterEvents(afterEventsCallback);48 expect(fakeServer.fetches).to(haveLength, 1);49 expect(User.find('sharon')).to(beNull);50 expect(Blog.find('guns')).to(beNull);51 fakeServer.lastFetch.simulateSuccess();52 expect(fakeServer.fetches).to(beEmpty);53 expect(beforeEventsCallback).to(haveBeenCalled);54 expect(insertCallback).to(haveBeenCalled);55 expect(afterEventsCallback).to(haveBeenCalled);56 expect(User.find('sharon').fullName()).to(eq, 'Sharon Ly');57 expect(Blog.find('guns').userId()).to(eq, 'sharon');58 });59 });60 describe("#create", function() {61 it("adds a request to the Server.creates array and assigns Server.lastCreate, which will perform the create when success is simulated", function() {62 var insertCallback = mockFunction('insertCallback');63 var successCallback = mockFunction('successCallback');64 User.onInsert(insertCallback);65 var record = User.build({fullName: "John Doe", age: 34});66 fakeServer.create(record).success(successCallback);67 expect(record.isRemotelyCreated).to(beFalse);68 expect(fakeServer.creates.length).to(eq, 1);69 expect(fakeServer.lastCreate).to(eq, fakeServer.creates[0]);70 fakeServer.lastCreate.simulateSuccess();71 expect(fakeServer.lastCreate).to(beNull);72 expect(fakeServer.creates).to(beEmpty);73 expect(record.isRemotelyCreated).to(beTrue);74 expect(record.id()).toNot(beNull);75 expect(insertCallback).to(haveBeenCalled);76 expect(insertCallback.mostRecentArgs[0]).to(eq, record);77 expect(successCallback).to(haveBeenCalled, withArgs(record));78 });79 it("performs the create immediately if the server is in auto-mode", function() {80 fakeServer.auto = true;81 var record = User.build({fullName: "John Doe", age: 34});82 expect(record.isRemotelyCreated).to(beFalse);83 fakeServer.create(record);84 expect(record.isRemotelyCreated).to(beTrue);85 });86 });87 describe("#update", function() {88 it("adds a request to the Server.updates array and assigns Server.lastUpdate, which will perform the update when success is simulated", function() {89 var updateCallback = mockFunction('updateCallback');90 var successCallback = mockFunction('successCallback');91 User.onUpdate(updateCallback);92 var record = User.createFromRemote({id: 1, fullName: "John Doe", age: 34});93 record.localUpdate({94 fullName: "John Deere",95 age: 5696 });97 fakeServer.update(record).success(successCallback);98 expect(record.dirty()).to(beTrue);99 expect(fakeServer.updates.length).to(eq, 1);100 expect(fakeServer.lastUpdate).to(eq, fakeServer.updates[0]);101 fakeServer.lastUpdate.simulateSuccess();102 expect(fakeServer.lastUpdate).to(beNull);103 expect(fakeServer.updates).to(beEmpty);104 expect(record.dirty()).to(beFalse);105 expect(record.localVersion).to(eq, 1);106 expect(record.remoteVersion).to(eq, 1);107 expect(record.pendingVersion).to(eq, 1);108 expect(record.fullName()).to(eq, "John Deere");109 expect(record.age()).to(eq, 56);110 var expectedChangeset = {111 fullName: {112 column: User.fullName,113 oldValue: "John Doe",114 newValue: "John Deere"115 },116 age: {117 column: User.age,118 oldValue: 34,119 newValue: 56120 }121 };122 expect(updateCallback).to(haveBeenCalled);123 expect(updateCallback.mostRecentArgs[0]).to(eq, record);124 expect(updateCallback.mostRecentArgs[1]).to(equal, expectedChangeset);125 expect(successCallback).to(haveBeenCalled, withArgs(record, expectedChangeset));126 });127 it("allows multiple updates to be interleaved", function() {128 var record = User.createFromRemote({id: 1, fullName: "John Doe", age: 34});129 record.localUpdate({130 fullName: "John 1",131 age: 1132 });133 fakeServer.update(record);134 expect(fakeServer.updates.length).to(eq, 1);135 expect(record.remoteVersion).to(eq, 0);136 expect(record.localVersion).to(eq, 1);137 expect(record.pendingVersion).to(eq, 1);138 record.localUpdate({139 fullName: "John 2"140 });141 expect(record.remoteVersion).to(eq, 0);142 expect(record.localVersion).to(eq, 2);143 expect(record.pendingVersion).to(eq, 1);144 fakeServer.update(record);145 expect(fakeServer.updates.length).to(eq, 2);146 expect(record.remoteVersion).to(eq, 0);147 expect(record.localVersion).to(eq, 2);148 expect(record.pendingVersion).to(eq, 2);149 fakeServer.updates[0].simulateSuccess();150 expect(record.remoteVersion).to(eq, 1);151 expect(record.local.fullName()).to(eq, "John 2");152 expect(record.remote.fullName()).to(eq, "John 1");153 fakeServer.updates[0].simulateSuccess();154 expect(record.remoteVersion).to(eq, 2);155 expect(record.local.fullName()).to(eq, "John 2");156 expect(record.remote.fullName()).to(eq, "John 2");157 });158 it("performs the update immediately if the server is in auto-mode", function() {159 fakeServer.auto = true;160 var record = User.createFromRemote({id: 1, fullName: "John Doe", age: 34});161 record.localUpdate({162 fullName: "John Deere",163 age: 56164 });165 fakeServer.update(record);166 expect(record.dirty()).to(beFalse);167 expect(record.age()).to(eq, 56);168 });169 });170 describe("#destroy", function() {171 it("adds a request to the Server.destroys array and assigns Server.lastDestroy, which will perform the destroy when success is simulated", function() {172 var removeCallback = mockFunction('removeCallback');173 var successCallback = mockFunction('successCallback');174 User.onRemove(removeCallback);175 var record = User.createFromRemote({id: 1, fullName: "John Doe", age: 34});176 fakeServer.destroy(record).success(successCallback);177 178 expect(User.find(1)).toNot(beNull);179 expect(fakeServer.destroys.length).to(eq, 1);180 expect(fakeServer.lastDestroy).to(eq, fakeServer.destroys[0]);181 fakeServer.lastDestroy.simulateSuccess();182 expect(fakeServer.lastDestroy).to(beNull);183 expect(fakeServer.destroys).to(beEmpty);184 expect(User.find(1)).to(beNull);185 expect(removeCallback).to(haveBeenCalled);186 expect(removeCallback.mostRecentArgs[0]).to(eq, record);187 expect(successCallback).to(haveBeenCalled, withArgs(record));188 });189 it("performs the destruction immediately if the server is in auto mode", function() {190 fakeServer.auto = true;191 var record = User.createFromRemote({id: 1});192 fakeServer.destroy(record);193 expect(User.find(1)).to(beNull);194 });195 });196 describe("#autoFetch", function() {197 it("immediately fetches tuples from the FakeServer's repository to the local repository", function() {198 expect(Blog.tuples()).to(beEmpty);199 fakeServer.autoFetch([Blog.table]);200 expect(Blog.tuples()).toNot(beEmpty);201 });202 });203 describe("#get, #put, #post, and #delete", function() {204 they("add fake requests to the fake server, which fire future callbacks and removes themselves when their success is simulated", function() {205 var successCallback = mockFunction('successCallback');206 var failureCallback = mockFunction('failureCallback');207 fakeServer.get('/foo', {foo: 'bar'})208 .onFailure(failureCallback);209 fakeServer.get('/bang', {glorp: 'buzz'})210 .success(successCallback);211 expect(fakeServer.gets.length).to(eq, 2);212 expect(fakeServer.lastGet).to(eq, fakeServer.gets[1]);213 expect(fakeServer.lastGet.url).to(eq, '/bang');214 expect(fakeServer.lastGet.data).to(equal, {glorp: 'buzz'});215 fakeServer.lastGet.simulateSuccess({baz: 'quux'});216 expect(successCallback).to(haveBeenCalled, withArgs({baz: 'quux'}));217 expect(fakeServer.gets.length).to(eq, 1);218 expect(fakeServer.lastGet).to(eq, fakeServer.gets[0]);219 expect(fakeServer.lastGet.url).to(eq, '/foo');220 expect(fakeServer.lastGet.data).to(equal, {foo: 'bar'});221 fakeServer.lastGet.simulateFailure({bar: 'foo'});222 expect(failureCallback).to(haveBeenCalled, withArgs({bar: 'foo'}));223 expect(fakeServer.gets).to(beEmpty);224 expect(fakeServer.lastGet).to(beNull);225 });226 });227 });...

Full Screen

Full Screen

analyticsDataSpec.js

Source:analyticsDataSpec.js Github

copy

Full Screen

1import { batchFetchPast30Days, batchFetchMonthlyPastYear } from '../../../scripts/metrics/analyticsData';2describe('analyticsData', function() {3 var fakeserver;4 beforeEach(function() {5 fakeserver = sinon.fakeServer.create();6 });7 afterEach(function() {8 fakeserver.restore();9 });10 describe('Tests for batchFetchMonthlyPastYear', function() {11 var successSpy, failSpy;12 var GA_ENDPOINT = CONFIG.JSON_LD_ID_BASE_URL + 'metrics/gadata/';13 var fetchParams = [14 {15 metrics: [{expression: 'ga:sessions'}],16 dimFilters : [{17 filters: [{dimensionName: 'ga:pagePath', operator: 'EXACT', expressions: ['pub/test']}]18 }]19 }, {20 metrics: [{expression: 'ga:eventCategory'}],21 dimFilters: [{22 operator: 'AND',23 filters: [24 {dimensionName: 'ga:pagePath', operator: 'EXACT', expressions: ['pub/test']},25 {dimensionName: 'ga:eventCategory', operator: 'EXACT', expressions: ['Downloads']}26 ]27 }]28 }29 ];30 beforeEach(function() {31 successSpy = jasmine.createSpy('successSpy');32 failSpy = jasmine.createSpy('failSpy');33 });34 it('Expects that the payload to the GA_ENDPOINT properly encodes the inputs', function() {35 var requestBody;36 batchFetchMonthlyPastYear(fetchParams);37 expect(fakeserver.requests.length).toBe(1);38 expect(fakeserver.requests[0].url).toEqual(GA_ENDPOINT);39 requestBody = $.parseJSON(fakeserver.requests[0].requestBody);40 expect(requestBody.length).toBe(2);41 expect(requestBody[0].dimensions[0].name).toEqual('ga:yearMonth');42 expect(requestBody[0].metrics).toEqual(fetchParams[0].metrics);43 expect(requestBody[0].dimensionFilterClauses).toEqual(fetchParams[0].dimFilters);44 expect(requestBody[1].dimensions[0].name).toEqual('ga:yearMonth');45 expect(requestBody[1].metrics).toEqual(fetchParams[1].metrics);46 expect(requestBody[1].dimensionFilterClauses).toEqual(fetchParams[1].dimFilters);47 });48 it('Expects that the dateRange is the past year from the date passed into the function', function() {49 var requestBody;50 batchFetchMonthlyPastYear(fetchParams, moment('20101015', 'YYYYMMDD'));51 requestBody = $.parseJSON(fakeserver.requests[0].requestBody);52 expect(requestBody[0].dateRanges.length).toBe(1);53 expect(requestBody[0].dateRanges[0].startDate).toEqual('2009-10-01');54 expect(requestBody[0].dateRanges[0].endDate).toEqual('2010-09-30');55 expect(requestBody[1].dateRanges.length).toBe(1);56 expect(requestBody[1].dateRanges[0].startDate).toEqual('2009-10-01');57 expect(requestBody[1].dateRanges[0].endDate).toEqual('2010-09-30');58 });59 it('Expects that a failed response will reject the promise', function() {60 fakeserver.respondWith([500, {'Content-Type' : 'text/html'}, 'Internal server error']);61 batchFetchMonthlyPastYear(fetchParams).done(successSpy).fail(failSpy);62 expect(successSpy).not.toHaveBeenCalled();63 expect(failSpy).not.toHaveBeenCalled();64 fakeserver.respond();65 expect(successSpy).not.toHaveBeenCalled();66 expect(failSpy).toHaveBeenCalled();67 });68 it('Expects that a successful response will resolve the promise', function() {69 fakeserver.respondWith([200, {'Content-Type' : 'application/json'},70 '{"reports" : [{"columnHeader" : {"metricHeader" : {"metricHeaderEntries" : [{"name" : "ga:sessions"}]}}}]}']);71 batchFetchMonthlyPastYear(fetchParams).done(successSpy).fail(failSpy);72 fakeserver.respond();73 expect(successSpy).toHaveBeenCalled();74 expect(failSpy).not.toHaveBeenCalled();75 });76 });77 describe('Tests for batchFetchPast30Days', function() {78 var successSpy, failSpy;79 var GA_ENDPOINT = CONFIG.JSON_LD_ID_BASE_URL + 'metrics/gadata/';80 var fetchParams = [81 {82 metrics: [{expression: 'ga:sessions'}],83 dimFilters : [{84 filters: [{dimensionName: 'ga:pagePath', operator: 'EXACT', expressions: ['pub/test']}]85 }]86 }, {87 metrics: [{expression: 'ga:eventCategory'}],88 dimFilters: [{89 operator: 'AND',90 filters: [91 {dimensionName: 'ga:pagePath', operator: 'EXACT', expressions: ['pub/test']},92 {dimensionName: 'ga:eventCategory', operator: 'EXACT', expressions: ['Downloads']}93 ]94 }]95 }96 ];97 beforeEach(function() {98 successSpy = jasmine.createSpy('successSpy');99 failSpy = jasmine.createSpy('failSpy');100 });101 it('Expects that the payload to the GA_ENDPOINT properly encodes the inputs', function() {102 var requestBody;103 batchFetchPast30Days(fetchParams);104 expect(fakeserver.requests.length).toBe(1);105 expect(fakeserver.requests[0].url).toEqual(GA_ENDPOINT);106 requestBody = $.parseJSON(fakeserver.requests[0].requestBody);107 expect(requestBody.length).toBe(2);108 expect(requestBody[0].dimensions[0].name).toEqual('ga:date');109 expect(requestBody[0].metrics).toEqual(fetchParams[0].metrics);110 expect(requestBody[0].dimensionFilterClauses).toEqual(fetchParams[0].dimFilters);111 expect(requestBody[1].dimensions[0].name).toEqual('ga:date');112 expect(requestBody[1].metrics).toEqual(fetchParams[1].metrics);113 expect(requestBody[1].dimensionFilterClauses).toEqual(fetchParams[1].dimFilters);114 });115 it('Expects that the dateRange is the past year from the date passed into the function', function() {116 var requestBody;117 batchFetchPast30Days(fetchParams, moment('20101015', 'YYYYMMDD'));118 requestBody = $.parseJSON(fakeserver.requests[0].requestBody);119 expect(requestBody[0].dateRanges.length).toBe(1);120 expect(requestBody[0].dateRanges[0].startDate).toEqual('2010-09-15');121 expect(requestBody[0].dateRanges[0].endDate).toEqual('2010-10-15');122 expect(requestBody[1].dateRanges.length).toBe(1);123 expect(requestBody[1].dateRanges[0].startDate).toEqual('2010-09-15');124 expect(requestBody[1].dateRanges[0].endDate).toEqual('2010-10-15');125 });126 it('Expects that a failed response will reject the promise', function() {127 fakeserver.respondWith([500, {'Content-Type' : 'text/html'}, 'Internal server error']);128 batchFetchPast30Days(fetchParams).done(successSpy).fail(failSpy);129 expect(successSpy).not.toHaveBeenCalled();130 expect(failSpy).not.toHaveBeenCalled();131 fakeserver.respond();132 expect(successSpy).not.toHaveBeenCalled();133 expect(failSpy).toHaveBeenCalled();134 });135 it('Expects that a successful response will resolve the promise', function() {136 fakeserver.respondWith([200, {'Content-Type' : 'application/json'},137 '{"reports" : [{"columnHeader" : {"metricHeader" : {"metricHeaderEntries" : [{"name" : "ga:sessions"}]}}}]}']);138 batchFetchPast30Days(fetchParams).done(successSpy).fail(failSpy);139 fakeserver.respond();140 expect(successSpy).toHaveBeenCalled();141 expect(failSpy).not.toHaveBeenCalled();142 });143 });...

Full Screen

Full Screen

setupRoutes.test.js

Source:setupRoutes.test.js Github

copy

Full Screen

1import proxyquire from 'proxyquire';2import assert from 'assert';3import sinon from 'sinon';4import winstonMock from './mocks/winston.mock';5import winstonDailyRotateFileMock from './mocks/winstonDailyRotateFile.mock';6import configMock from './mocks/config.mock';7const wrapEndpointSpy = sinon.spy();8const setupRoutes = proxyquire('../../src/setupRoutes', {9 'winston': { ...winstonMock, '@noCallThru': true, '@global': true },10 'winston-daily-rotate-file': winstonDailyRotateFileMock,11 './config': { ...configMock, '@noCallThru': true, '@global': true },12 '../../config': { ...configMock, '@noCallThru': true, '@global': true },13 './createContext': { default: () => ({}) },14 './wrapEndpoint': { default: wrapEndpointSpy }15}).default;16describe('setupRoutes.js', () => {17 beforeEach(() => {18 wrapEndpointSpy.resetHistory();19 });20 describe('setupRoutes(server)', () => {21 let fakeServer;22 beforeEach(() => {23 fakeServer = {24 get: sinon.spy(),25 post: sinon.spy(),26 del: sinon.spy(),27 patch: sinon.spy(),28 put: sinon.spy()29 };30 });31 it('registers the route GET /v1/info', () => {32 setupRoutes(fakeServer);33 assert(fakeServer.get.called);34 assert(fakeServer.get.calledWithMatch('/v1/info'));35 });36 it('registers the route GET /v1/users', () => {37 setupRoutes(fakeServer);38 assert(fakeServer.get.called);39 assert(fakeServer.get.calledWithMatch('/v1/users'));40 });41 it('registers the route POST /v1/users', () => {42 setupRoutes(fakeServer);43 assert(fakeServer.post.called);44 assert(fakeServer.post.calledWithMatch('/v1/users'));45 });46 it('registers the route GET /v1/users/:id', () => {47 setupRoutes(fakeServer);48 assert(fakeServer.get.called);49 assert(fakeServer.get.calledWithMatch('/v1/users/:id'));50 });51 it('registers the route PATCH /v1/users/:id', () => {52 setupRoutes(fakeServer);53 assert(fakeServer.patch.called);54 assert(fakeServer.patch.calledWithMatch('/v1/users/:id'));55 });56 it('registers the route GET /v1/users/:userId/avatar', () => {57 setupRoutes(fakeServer);58 assert(fakeServer.get.called);59 assert(fakeServer.get.calledWithMatch('/v1/users/:userId/avatar'));60 });61 it('registers the route PUT /v1/users/:userId/avatar', () => {62 setupRoutes(fakeServer);63 assert(fakeServer.put.called);64 assert(fakeServer.put.calledWithMatch('/v1/users/:userId/avatar'));65 });66 it('registers the route POST /v1/users/:userId/device-tokens', () => {67 setupRoutes(fakeServer);68 assert(fakeServer.post.called);69 assert(fakeServer.post.calledWithMatch('/v1/users/:userId/device-tokens'));70 });71 it('registers the route DELETE /v1/users/:userId/device-tokens/:id', () => {72 setupRoutes(fakeServer);73 assert(fakeServer.del.called);74 assert(fakeServer.del.calledWithMatch('/v1/users/:userId/device-tokens/:id'));75 });76 it('registers the route GET /v1/users/:userId/contact-requests', () => {77 setupRoutes(fakeServer);78 assert(fakeServer.get.called);79 assert(fakeServer.get.calledWithMatch('/v1/users/:userId/contact-requests'));80 });81 it('registers the route POST /v1/users/:userId/contact-requests', () => {82 setupRoutes(fakeServer);83 assert(fakeServer.post.called);84 assert(fakeServer.post.calledWithMatch('/v1/users/:userId/contact-requests'));85 });86 it('registers the route DELETE /v1/users/:userId/contact-requests/:id', () => {87 setupRoutes(fakeServer);88 assert(fakeServer.del.called);89 assert(fakeServer.del.calledWithMatch('/v1/users/:userId/contact-requests/:id'));90 });91 it('registers the route GET /v1/users/:userId/contacts', () => {92 setupRoutes(fakeServer);93 assert(fakeServer.get.called);94 assert(fakeServer.get.calledWithMatch('/v1/users/:userId/contacts'));95 });96 it('registers the route POST /v1/users/:userId/contacts', () => {97 setupRoutes(fakeServer);98 assert(fakeServer.post.called);99 assert(fakeServer.post.calledWithMatch('/v1/users/:userId/contacts'));100 });101 it('registers the route DELETE /v1/users/:userId/contacts/:id', () => {102 setupRoutes(fakeServer);103 assert(fakeServer.del.called);104 assert(fakeServer.del.calledWithMatch('/v1/users/:userId/contacts/:id'));105 });106 it('registers the route GET /v1/users/:userId/address', () => {107 setupRoutes(fakeServer);108 assert(fakeServer.get.called);109 assert(fakeServer.get.calledWithMatch('/v1/users/:userId/address'));110 });111 it('registers the route POST /v1/users/:userId/address/used', () => {112 setupRoutes(fakeServer);113 assert(fakeServer.post.called);114 assert(fakeServer.post.calledWithMatch('/v1/users/:userId/address/used'));115 });116 it('registers the route POST /v1/users/:userId/messages', () => {117 setupRoutes(fakeServer);118 assert(fakeServer.post.called);119 assert(fakeServer.post.calledWithMatch('/v1/users/:userId/messages'));120 });121 it('registers the route GET /v1/users/:userId/messages', () => {122 setupRoutes(fakeServer);123 assert(fakeServer.get.called);124 assert(fakeServer.get.calledWithMatch('/v1/users/:userId/messages'));125 });126 it('registers the route DELETE /v1/users/:userId/messages/:id', () => {127 setupRoutes(fakeServer);128 assert(fakeServer.del.called);129 assert(fakeServer.del.calledWithMatch('/v1/users/:userId/messages/:id'));130 });131 it('registers the route POST /v1/users/:userId/lightning/invoices', () => {132 setupRoutes(fakeServer);133 assert(fakeServer.post.called);134 assert(fakeServer.post.calledWithMatch('/v1/users/:userId/lightning/invoices'));135 });136 it('registers the route GET /v1/users/:userId/lightning/invoices/unredeemed', () => {137 setupRoutes(fakeServer);138 assert(fakeServer.get.called);139 assert(fakeServer.get.calledWithMatch('/v1/users/:userId/lightning/invoices/unredeemed'));140 });141 it('registers the route GET /v1/users/:userId/lightning/invoices/:id', () => {142 setupRoutes(fakeServer);143 assert(fakeServer.get.called);144 assert(fakeServer.get.calledWithMatch('/v1/users/:userId/lightning/invoices/:id'));145 });146 it('registers the route POST /v1/users/:userId/lightning/invoices/:invoiceId/redeem', () => {147 setupRoutes(fakeServer);148 assert(fakeServer.post.called);149 assert(fakeServer.post.calledWithMatch('/v1/users/:userId/lightning/invoices/:invoiceId/redeem'));150 });151 it('registers the route GET /v1/users/:userId/lightning/capacity', () => {152 setupRoutes(fakeServer);153 assert(fakeServer.get.called);154 assert(fakeServer.get.calledWithMatch('/v1/users/:userId/lightning/capacity'));155 });156 it('wraps each endpoint with wrapEndpoint()', () => {157 setupRoutes(fakeServer);158 assert.equal(wrapEndpointSpy.callCount, 25);159 });160 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var pact = require('pact-foundation-pact-node');2var path = require('path');3var server = pact.createServer({4 log: path.resolve(process.cwd(), 'logs', 'pact.log'),5 dir: path.resolve(process.cwd(), 'pacts'),6});7server.start();8var pact = require('pact');9var server = pact.createServer({10 log: path.resolve(process.cwd(), 'logs', 'pact.log'),11 dir: path.resolve(process.cwd(), 'pacts'),12});13server.start();14var pact = require('pact-node');15var server = pact.createServer({16 log: path.resolve(process.cwd(), 'logs', 'pact.log'),17 dir: path.resolve(process.cwd(), 'pacts'),18});19server.start();20var pact = require('pact-foundation-pact-node');21var path = require('path');22var server = pact.createServer({23 log: path.resolve(process.cwd(), 'logs', 'pact.log'),24 dir: path.resolve(process.cwd(), 'pacts'),25});26server.start();27var pact = require('pact');28var server = pact.createServer({29 log: path.resolve(process.cwd(), 'logs', 'pact.log'),30 dir: path.resolve(process.cwd(), 'pacts'),31});32server.start();33var pact = require('pact-node');34var server = pact.createServer({

Full Screen

Using AI Code Generation

copy

Full Screen

1var fakeServer = require('pact-foundation-pact-node').fakeServer;2describe('Pact', function() {3 describe('fakeServer', function() {4 it('should respond with a 200', function(done) {5 fakeServer.start();6 expect(response.statusCode).to.eql(200);7 done();8 });9 });10 });11});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pact-foundation-pact 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