Created
October 17, 2017 09:51
-
-
Save samsamm777/5464f31fd0027df8c5d6daca0e256983 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 {TestBed} from '@angular/core/testing'; | |
import {ArtworkService} from './artwork.service'; | |
import * as path from 'path'; | |
import {remote} from 'electron'; | |
//import * as child from 'child_process'; | |
import * as ChildProcess from 'child_process'; | |
//import {spawn} from 'child_process'; | |
import {shell} from 'electron'; | |
//import * as et from 'electron'; | |
//const child = remote.require('child_process'); | |
//let fs = require('fs'); | |
//import {fileExists} from 'ts-node/dist'; | |
//import {ConfigManager} from '../../../main-process/config/config.manager'; | |
//import {ConfigFactory} from '../../../main-process/config/config.factory'; | |
const testFilename = '/flixDev/flix-6a-client/0001g.jpg'; | |
const testFilenames: string[] = ['testfile.jpg', 'testFile2.jpg', 'testFile3.jpg', '/flixDev/flix-6a-client/0001g.jpg']; | |
let artworkService: ArtworkService; | |
fdescribe('Artwork Service', specDefinition); | |
function specDefinition() { | |
beforeEach(setup); | |
it('should be given an existing file', testFileExists); | |
// it('should have viewed a set of files', viewFiles); | |
// it('should have edited a set of files', editFiles); | |
// it('should use electron code', electronTest); | |
it('should spawn', testSpawn); | |
} | |
function setup() { | |
TestBed.configureTestingModule({ | |
providers: [ | |
ArtworkService | |
// ,ConfigManager | |
] | |
} | |
); | |
artworkService = TestBed.get(ArtworkService) | |
} | |
function testFileExists() { | |
const exists = artworkService.artworkExists(testFilename); | |
expect(exists).toBe(true); | |
shell.openExternal(testFilename, {activate: true}, (error) => { | |
console.log('openExternal:', error) | |
}) | |
} | |
//function viewFiles() { | |
// spyOn(artworkService, 'artworkExists').and.callFake((fileName) => true); | |
// artworkService.viewArtwork(testFilenames); | |
// expect(artworkService.fileCount).toBe(testFilenames.length); | |
// expect(artworkService.failedCount).toBe(0); | |
//} | |
function testSpawn() { | |
// const p = ChildProcess.spawn('/Applications/Preview.app', [testFilename]); | |
// p.stdout.on('data', (data) => { | |
// console.log('testSpawn:', data); | |
// }); | |
expect(false).toBe(true); | |
} | |
function editFiles() { | |
spyOn(artworkService, 'artworkExists').and.callFake((fileName) => true); | |
artworkService.editArtwork(testFilenames); | |
expect(artworkService.fileCount).toBe(testFilenames.length); | |
expect(artworkService.failedCount).toBe(0); | |
} | |
function electronTest() { | |
const fs = remote.require('fs'); | |
console.log('electronTest:', fs.existsSync(testFilename)); | |
console.log('electronTest:', path.isAbsolute(testFilename)); | |
// console.log('electronTest:', fs.exists(testFilename, (x) => { | |
// console.log('electronTest.fs.stat:', x); | |
// })) | |
expect(false).toEqual(true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment