Skip to content

Commit

Permalink
feat(create-json-from-ts-function): log the creation of the typescrip…
Browse files Browse the repository at this point in the history
…t file templates just like the
  • Loading branch information
vespertilian committed Jun 8, 2018
1 parent 902cafb commit e7d51d0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('.createJSONFromTemplatesAndZoneData', () => {
.createSpy('createJSONFromHandlebarsTemplates');

const createJSONFromTsFunctionSpy = jasmine
.createSpy('createJSONFromHandlebarsTemplates');
.createSpy('createJSONFromTsFunction');

const getIANATzDataStub = jasmine.createSpy('getIANATzDataSpy')
.and.returnValue(fakeIANAData());
Expand All @@ -25,9 +25,9 @@ describe('.createJSONFromTemplatesAndZoneData', () => {
createJSONFromTsFunctionSpy
);

// TODO update test to check createJSONFromTsFunctionSpy
// check default params
expect(createJSONFromHandlebarsTemplatesSpy).toHaveBeenCalledTimes(1);
expect(createJSONFromTsFunctionSpy).toHaveBeenCalledTimes(1);

const firstCallParams: ICreateJSONFromTemplatesParams =
createJSONFromHandlebarsTemplatesSpy.calls.argsFor(0)[0];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const defaultSettings: ICreateJSONSettings = {
zoneFileNames: ['zone1970.tab']
};


export interface ICreateJSONFromTemplatesParams{
templateFileNames: string [],
extractedZoneData: IExtractedTimezoneData,
Expand Down Expand Up @@ -50,7 +49,6 @@ export async function createJSONFromTemplatesAndZoneData(
saveDirectory
});

// TODO test
await _createJSONFromTsFunctions({
templateFileNames: typescriptFiles,
extractedZoneData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,21 @@ describe('.createJSONFromTsFunctions', () => {
.createSpy('writeFileAsyncSpy');

const ensureExistsAsync = jasmine.createSpy('ensureExists');
const logSpy = jasmine.createSpy('console.log');

await createJsonFromTsFunctions(params, writeFileAsyncStub, ensureExistsAsync);
await createJsonFromTsFunctions(
params,
writeFileAsyncStub,
ensureExistsAsync,
logSpy
);

const fileWritePath = writeFileAsyncStub.calls.first().args[0];
const jsonString = writeFileAsyncStub.calls.first().args[1].toString();

// logs file creation
expect(logSpy).toHaveBeenCalledWith('Creating JSON for: test.ts with foo-zone.tab');

expect(fileWritePath).toEqual('dira/dirb/saveDirFoo/sample-data-1-foo-zone-file-a.json');
expect(JSON.parse(jsonString)).toEqual({a: 1});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ export async function createJsonFromTsFunctions(
) {
const {templateFileNames, extractedZoneData, templatesPath, zoneFileName, saveDirectory} = params;


// TODO log the files we are creating
for(const filenamePath of params.templateFileNames) {
_log(`Creating JSON for: ${filenamePath} with ${zoneFileName}`);
const fullFilePath = `${params.templatesPath}/${filenamePath}`;
const fullFilePathWithoutExtension = fullFilePath.slice(0, fullFilePath.lastIndexOf('.'));

Expand Down

0 comments on commit e7d51d0

Please sign in to comment.