Skip to content

Commit

Permalink
updated tests to check if output directory exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Hayes committed Oct 3, 2020
1 parent 3736f65 commit e262e7c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
20 changes: 18 additions & 2 deletions tests/api-convert.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
const fs = require("fs");
const fsExtra = require('fs-extra')
const { convertFont } = require('../src/index')
const fileIn = './tests/fonts/Roboto-Regular'
const fileOut = './tests/output/Roboto-Regular'
const fileName = 'Roboto-Regular'
const fileIn = `./tests/fonts/${fileName}`
const fileOut = `./tests/output/${fileName}`

const createOutputDirectory = () => {
if (!fs.existsSync('./tests/output/')){
fs.mkdirSync('./tests/output/');
}
}

describe('TTF input font tests', () => {
beforeAll(() => {
createOutputDirectory()
})
afterAll(() => {
fsExtra.emptyDirSync('./tests/output/')
});
Expand All @@ -22,6 +32,9 @@ describe('TTF input font tests', () => {
})

describe('OTF input font tests', () => {
beforeAll(() => {
createOutputDirectory()
})
afterEach(() => {
fsExtra.emptyDirSync('./tests/output/')
});
Expand Down Expand Up @@ -52,6 +65,9 @@ describe('OTF input font tests', () => {
})

describe('SVG input font tests', () => {
beforeAll(() => {
createOutputDirectory()
})
afterEach(() => {
fsExtra.emptyDirSync('./tests/output/')
});
Expand Down
15 changes: 13 additions & 2 deletions tests/api-fonts.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
const fs = require("fs");
const fsExtra = require('fs-extra')
const fonts = require('../src/lib/fonts')
const fileIn = './tests/fonts/Roboto-Regular'
const fileOut = './tests/output/Roboto-Regular'
const fileName = 'Roboto-Regular'
const fileIn = `./tests/fonts/${fileName}`
const fileOut = `./tests/output/${fileName}`

const createOutputDirectory = () => {
if (!fs.existsSync('./tests/output/')){
fs.mkdirSync('./tests/output/');
}
}

beforeAll(() => {
createOutputDirectory()
})

afterEach(() => {
fsExtra.emptyDirSync('./tests/output/')
Expand Down
Empty file removed tests/output/.gitkeep
Empty file.

0 comments on commit e262e7c

Please sign in to comment.