|
| 1 | +import test from 'tape' |
| 2 | +import sinon from 'sinon' |
| 3 | +import runContentfulImport from '../lib/run-contentful-import' |
| 4 | +import Promise from 'bluebird' |
| 5 | +const createClientsStub = sinon.stub().returns({ source: {delivery: {}}, destination: {management: {}} }) |
| 6 | +runContentfulImport.__Rewire__('createClients', createClientsStub) |
| 7 | +const getTransformedDestinationResponse = sinon.stub().returns( |
| 8 | + Promise.resolve({contentTypes: [], entries: [], assets: [], locales: []}) |
| 9 | +) |
| 10 | +runContentfulImport.__Rewire__('getTransformedDestinationResponse', getTransformedDestinationResponse) |
| 11 | + |
| 12 | +const transformSpaceStub = sinon.stub().returns(Promise.resolve({contentTypes: [], entries: [], assets: [], locales: []})) |
| 13 | +runContentfulImport.__Rewire__('transformSpace', transformSpaceStub) |
| 14 | +const pushToSpaceStub = sinon.stub().returns(Promise.resolve({})) |
| 15 | +runContentfulImport.__Rewire__('pushToSpace', pushToSpaceStub) |
| 16 | +test('Runs Contentful Import', (t) => { |
| 17 | + runContentfulImport({ |
| 18 | + opts: {}, |
| 19 | + errorLogFile: 'errorlogfile' |
| 20 | + }) |
| 21 | + .then(() => { |
| 22 | + t.ok(createClientsStub.called, 'create clients') |
| 23 | + t.ok(transformSpaceStub.called, 'transform space') |
| 24 | + t.ok(pushToSpaceStub.called, 'push to space') |
| 25 | + runContentfulImport.__ResetDependency__('createClients') |
| 26 | + runContentfulImport.__ResetDependency__('transformSpace') |
| 27 | + runContentfulImport.__ResetDependency__('pushToSpace') |
| 28 | + t.end() |
| 29 | + }) |
| 30 | +}) |
| 31 | + |
0 commit comments